Discrete Random Variables

R commands and functions:

- # - comments out code
- runif(n) - generates n draws from standard uniform distribution
- round(x) - rounds x to the nearest integer
- sum(v) - sums elements of vector v
- mean(v) - averages elements of vector v
- v [ i : j ] - looks at elements from vector v indexed from i to j

R commands and functions:

- a < b - returns TRUE if a is less than b and FALSE otherwise
- rbinom(n,1,p) - generates n draws from bernoulli distribution distribution with parameter p

R commands and functions:

- hist(v) - represents data from vector v in a histogram
- rbinom(n,m,p) - generates n draws from binomial distribution distribution with parameters m and p

Mathematical formulas:

R commands and functions:

- 1:n - generates a vector of n integers
- matrix(nrow=n,ncol=m) - generates empty matrix of n rows and m columns
- for(i in v){do} - repeats do command for i taking all the values from vector v

R commands and functions:

- while(bool){do} - repeats do command while bool logical condition is TRUE
- rgeom(n,p) - generates n draws from geometric distribution with parameter p
- 1+e6 - short notation for 10 to power 6

Mathematical formulas:

R commands and functions:

- max(v) - returns maximal element in data set v
- na.rm=TRUE - optional function argument making it ignore NA values
- .Machine$Double.eps - returns lowest in absolute value number of type double

R commands and functions:

- f=function(x){return(x*x)} - function syntax in R, f(3) returns square of 3
- print(x) - prints value of x in console
- flush.console() - forces output display
- Sys.sleep(x) - holds execution for x sec

Mathematical formulas:

Borel - Cantelli lemma part 2:

R commands and functions:

- .Machine$integer.max - returns maximal number od type integer
- sqrt(x) - square root of x
- if(bool){do} - executes do command if bool logical condition is TRUE