"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" ;

September 22, 2015

R Working on Normal Distributions & Binomial Distributions


Cumulative density function - CDF is summation of all the probabilities within a range. The CDF is the integral of the PDF (Probability density function).

Read Jack Lion Heart's answer to What is the difference between a probability density function and a cumulative distribution function? on Quora
  • “d” - returns the height of the probability density function
  • “p” - returns the cumulative density function
  • “q” - returns the inverse cumulative density function (quantiles)
  • “r” - returns randomly generated numbers
Reference - Link

R Examples
pnorm(700,500,100)
Mean - 500
Variance - 100

This score 700 is better than 97% of other scores

v <- c(-1,1,2)
dnorm(v)
plot(v,dnorm(v))
plot(v,pnorm(v))
dnorm(0,mean(v),sd(v))

Link Ref

Normal distribution is defined by the following probability density function, where μ is the population mean and σ2 is the variance.

Chi-squared Distribution - If X1,X2,…,Xm are m independent random variables having the standard normal distribution, then the following quantity follows a Chi-Squared distribution with m degrees of freedom

Binormial Distribution - binomial distribution is a discrete probability distribution. It describes the outcome of n independent trials in an experiment. 

Two Extra Parameters - number of trials and the probability of success for a single trial

Distribution function
x <- seq(0,50,by=1)
y <- dbinom(x,50,0.2)
plot(x,y)

50 - Number of Trials
0.2 - Probability of success for each trial

Cumulative Probability Density Function
x <- seq(0,50,by=1)
y <- pbinom(x,50,0.5)
plot(x,y)

50 - Number of Trials
0.5 - Probability of success for each trial

Random Probability Density Function
x <- seq(0,50,by=1)
y <- rbinom(x,50,0.5)
plot(x,y)

Happy Learning, More Learning Needed...It's vast....Lot more efforts needed :)

No comments: