Difference between revisions of "R: Matematika Dasar"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) |
Onnowpurbo (talk | contribs) |
||
Line 50: | Line 50: | ||
sum(1:3) | sum(1:3) | ||
− | |||
prod(c(3,5,7)) | prod(c(3,5,7)) | ||
− | |||
min(c(1,6,-14,-154,0)) | min(c(1,6,-14,-154,0)) | ||
− | |||
max(c(1,6,-14,-154,0)) | max(c(1,6,-14,-154,0)) | ||
− | |||
range(c(1,6,-14,-154,0)) | range(c(1,6,-14,-154,0)) | ||
− | |||
− | |||
any(c(1,6,-14,-154,0)<0) | any(c(1,6,-14,-154,0)<0) | ||
+ | which(c(1,6,-14,-154,0)<0) | ||
+ | all(c(1,6,-14,-154,0)<0) # all checks if criteria is met by each element | ||
− | |||
− | + | ==Complex== | |
+ | # Plot of Characteristic Function of a U(-1,1) Random Variable | ||
+ | a <- -1; b <- 1 | ||
+ | t <- seq(-20,20,.1) | ||
+ | chu <- (exp(1i*t*b)-exp(1i*t*a))/(1i*t*(b-a)) | ||
+ | plot(t,chu,"l",ylab=(expression(varphi(t))),main="Characteristic Function of Uniform Distribution [-1, 1]") | ||
==Trigonometry== | ==Trigonometry== |
Revision as of 09:36, 28 November 2019
Contoh operasi matematika
2 ^ 2
2 * 2
2 / 2
2 + 2
2 - 2
4 * 3 ^ 3
vector -4 s/d 3
-4:3
abs remainder
absolute
abs(-4:3)
remainder
(-4:3) %% 2
(-4:3) %/% 3
sign
sign(-4:3)
round
round(7/18,2)
7/118
options(digits=2) 7/118
floor(0.39)
ceiling(0.39)
summary functions
sum(1:3) prod(c(3,5,7)) min(c(1,6,-14,-154,0)) max(c(1,6,-14,-154,0)) range(c(1,6,-14,-154,0))
any(c(1,6,-14,-154,0)<0) which(c(1,6,-14,-154,0)<0) all(c(1,6,-14,-154,0)<0) # all checks if criteria is met by each element
Complex
# Plot of Characteristic Function of a U(-1,1) Random Variable a <- -1; b <- 1 t <- seq(-20,20,.1) chu <- (exp(1i*t*b)-exp(1i*t*a))/(1i*t*(b-a)) plot(t,chu,"l",ylab=(expression(varphi(t))),main="Characteristic Function of Uniform Distribution [-1, 1]")
Trigonometry
sin(pi/2)
tan(pi/4)
cos(pi)