Normal Distribution Normal Distribution is the most widely known and used of all distributions. It fits the distribution of many human characteristics (height,weight,IQ scores,etc.), and also explains characteristics of living things in nature (trees,animals). It is a continuous distribution, it is symmetric about the mean, unimodal,bell shaped, and applies the empirical rule. It takes a mean and standard deviation as parameters.
Binomial Distribution Binomial distribution describes the probability of achieveing a specific number of successes in a fixed number of binomial trials. There are 4 conditions for a binomial distribution: 1.The trials are independent.2.The number of trials is fixed (n).3.only 2 outcomes to a trial(success,failure).4. The probability of success (p) is the same for each trial.
Poisson Distribution Poisson distribution is used for estimating the number of events in a large population, over a unit of time(interval). It is an approximation to the binomial distribution. The interval may be time, distance, area, or volume. The probability of a Poisson distribution is proportional to the length of the interval. The intervals are independent.
A PDF(Probability Density Function) describes the likelihood, or
rate, of a continuous random variable ending up within a specific range.
To calculate the probability of the random var falling in a specific
range, you need to calculate the area under the PDF curve between the
minimum and maximum of the desired range. The total area under the curve
always equals to 1.
Applying the PDF formula to binomial distribution will not work because
binomial distribution is discrete. It takes only whole numbers, and not
variables that can expand over a range or values. Instead, binomial
distribution uses Probability Mass Function to get the number of ways of
getting exactly x successes of N trials.
CDF(Cumulative Distribution Function) provides the probability that the random variable will take a value less than or equal to a particular number.It basically adds up all the probabilities up to a certain value. The grpah of a CDF is a non-decreasing curve that starts as zero and getting closer to 1 as x increases.
The key parameters to each distribution:
Normal Distribution - mean, and standard deviation. Mean gives you the center of the values/data. The standard deviation determines the spread of the data around the mean.How far data may be from the center.
Binomial Distribution - number of trials(n), and probability of success of each trial (p). Binomial distribution checks the probability of getting a specific number of successes out of a fixed number of trials, so it required both number of successes and trials.
Poisson Distribution - average number of events per interval (lambda). Poisson distribution uses the lambda to check the probability of observing a specific number of events over a fixed unit of time.
?distribution
## starting httpd help server ... done
R required parameters mean and sd for normal distribution. dnorm(x, mean = 0, sd = 1, log = FALSE)
R requires parameters size and prob for binomial distribution. dbinom(x, size, prob, log = FALSE)
R requires parameters lambda for poisson distribution dpois(x, lambda, log = FALSE)
Some examples that can be modeled with each distibution:
Normal distribution: 1. Weight of soccer cleats. 2. Blood glucose levels. 3. SAT test scores
Binomial distribution: 1. Number of tails from 15 coin tosses. 2. Number of free throws made out of 10 attempts. 3. Number of students who pass a test out of 40 students. Assuming each student has the same probability of passing the test.
Poisson distribution: 1. Number of calls received by a call center per minute. 2. Number of road fatalities in an intersection per month. 3. Number of costumers arriving at a store per hour.
Lets plot a binomial distribution that shows the probability of an NBA player making 0 through 10 free throws from 10 attempts.According to Basketball Reference, the average free throw probability in the NBA is 77%.
#number of trials
n <- 10
#probability of success
p <- 0.77
#values for x
x <- 0:n
#calculate the probability for each
probabilities <- dbinom(x=x,size=n,prob=p)
# plot the binomial distribution
barplot(height = probabilities,
names.arg=x,
col= "yellow",
main= "Free throw distribution",
xlab="Number of Successes",
ylab="Probability",
#extending the y axis range
ylim = c(0, 0.30)
)
I am curious to find the probability of exactly 7 successful free throws out of 10 attmepts.
dbinom(7,10,0.77)
## [1] 0.2343149
There is 23.4% percent that the average NBA player will score 7 out of 10 free throws attempts. It is a bit surprising, I thought the probability would be higher.
PART II. Converge of Distributions
I picked: N=100 x=8 pi=0.02
I will model the binomial distribution first
#number of procedures
n <- 100
#probability of death
p <- 0.02
#values for x
x <- 0:10
#calculate the probability for each
probabilities <- dbinom(x=x,size=n,prob=p)
# plot the binomial distribution
barplot(height = probabilities,
names.arg=x,
col= "red",
main= "Deaths within 30 days - Binomial",
xlab="Number of deaths",
ylab="Probability",
ylim = c(0, max(probabilities) * 1.1)
)
Now I will check rates and determine is the hospital’s proportion of deaths is extreme
#national death rate
pi<-0.02
# observing 8 or more deaths
prob <- 1-pbinom(7,100,0.02)
#converting to percentage
prob <- prob*100
prob
## [1] 0.093194
The probability of observing 8 or more deaths from 100 procedures, assuming a national death rate of 2%, is approximately 0.093%. It will be considered unusually high outcome comparing to the national rate.
Now to model the Poisson distribution
#expected number of deaths
lambda <- 100*0.02
#values for x
x <- 0:10
#calculate probability for each number of deaths
probabilities <- dpois(x=x,lambda = lambda)
#plot the distribution
barplot(height = probabilities,
names.arg = x,
col = "blue",
main = "Deaths within 30 days - Poisson",
xlab = "Number of deaths",
ylab = "Probability",
ylim = (c(0,max(probabilities)*1.3))
)
Now I will check the probability of observing 8 or more deaths
prob <- 1 - ppois(7,lambda = 2)
#converting to percentage
prob <- prob * 100
prob
## [1] 0.1096719
With the average of 2 deaths expected per 100 procedures, there is only 0.11% chance of observing 8 or more deaths.This will be very surprising if it happens, as the binomial distribution showed as well.
I did get similar answers. Binomial was 0.093%, while Poisson was 0.11%. The answers are not identical because binomial checks exactly 100 procedures, while Poisson gives an approximation for death rate per 100 procedures.