"No one is harder on a talented person than the person themselves" - Linda Wilkinson ; "Trust your guts and don't follow the herd" ; "Validate direction not destination" ;

May 03, 2016

Day #19 - Probability Basics

Concepts
  • Events - Subset of Sample Space
  • Sample Space - Set of all possible outcomes
  • Random Variable - Outcome of experiment captured by Random variable
  • Permutation - Ordering matters
  • Combination - Ordering does not matter
  • Binomial - Only two outcomes of trail
  • Poisson - Events that take place over and over again. Rate of Event denoted by lambda
  • Geometric - Suppose you'd like to figure out how many attempts at something is necessary until the first success occurs, and the probability of success is the same for each trial and the trials are independent of each other, then you'd want to use the geometric distribution
  • Conditional Probability - P(A Given B) = P(A) will occur assume B has already occurred
  • Normal Distribution - Appears because of central limit theorem (Gaussian and Normal Distribution both are same)
From Quora -  
"Consider a binomial distribution with parameters n and p. The distribution is underlined by only two outcomes in the run of an independent trial- success and failure. A binomial distribution converges to a Poisson distribution when the parameter n tends to infinity and the probability of success p tends to zero. These extreme behaviours of the two parameters make the mean constant i.e. n*p = mean of Poisson distribution "

Read Michael Lamar's answer to Probability (statistics): What is difference between binominal, poisson and normal distribution? on Quora
#binomial binom discrete
#Poisson pois discret
#normal norm continuous
#chi-squared chisq continuous
#Student's t t continuous
#uniform unif continuous
#dnorm
#height of the probability density function
#dnorm() function returns the height of the normal curve at some value along the x-axis
dnorm(1)
#you can specify "mean=" and "sd="
#dnorm(x, mean, sd) - Height of pdf
dnorm(1,mean=5,sd=2)
#pnorm
#cumulative density function
#It returns the area below the given value of "x"
pnorm(1)
#pnorm(q, mean, sd)
#Left of standard normal curve
pnorm(1.96, 0, 1)
#qnorm
#quantiles or "critical values", you can use the qnorm()
qnorm(.95)
#qnorm(p, mean, sd)
qnorm(0.975, 0, 1)
#rnorm
#normally distributed random nos.
#rnorm(n, mean, sd) will create a vector of length n containing independent,
x = rnorm(9)
hist(x)
#Generate 100 numbers from a normal distribution with mean 5 and sd 0.25
x = rnorm(100, mean=5, sd=.25)
hist(x)
#dbinorm - binomial
#dbinom(x, s, p)
#vector of values, x, sample size s and probability of success p
#report the probability of seeing exactly the number of successes denoted by each value of x
V = dbinom(0:7, 7, .3)
V
barplot(table(V))
#rbinom(n, s, p) will create a vector of length n containing independent,
#random draws from a binomial distribution with the size of s and the probability of success p.
#Bernouli spaces, two outcomes
rbin(N,n,p)
#binomial - number of successes in a sequence of n independent yes/no experiments
#assign 100 independent binomial numbers with parameters n = 7 and p = .3 to a vector object called V.
#binomial random numbers
V <- rbinom(100, 7, .3)
barplot(table(V))
#poisson
#Event occurs again and again
#100 independent Poisson numbers with parameter λ = 0.7 to a vector object called V
#Poisson distribution - given number of events occurring in a fixed interval of time and/or space
V <- rpois(100, 0.7)
barplot(table(V))
#Geometric
#something is necessary until the first success
#Example: Products produced by a machine has a 3% defective rate.
#What is the probability that the first defective occurs in the fifth item inspected?
#P(X = 5) = P(1st 4 non-defective )P( 5th defective)
dgeom (x= 4, prob = .03)
Happy Learning!!!!

No comments: