Showing posts with label Distribution. Show all posts
Showing posts with label Distribution. Show all posts

Gamma & Exponential Distribution Explained...

In this post we will be discussing two Distribution that are close cousin of each others i.e. Gamma & Exponential Distributions. While most of the problems in every day life can be solved with Normal Distribution, not every thing can be solved with them. 

Gamma & Exponential Process are frequently found in the Engineering and Management sciences, particularly in Queuing Models and Simulation of Working of various Electrical and Mechanical components for their life (Reliability Analysis) in case of Exponential distribution. 


So First we go with a standard Definition of these two Distributions from Wikipeida: 

In probability theory and statistics, the Exponential distribution (a.k.a. negative exponential distribution) is a family of continuous probability distributions. It describes the time between events in a Poisson process, i.e. a process in which events occur continuously and independently at a constant average rate. It is the continuous analogue of thegeometric distribution
and...
In probability theory and statistics, the Gamma distribution is a two-parameter family of continuous probability distributions. There are three different parameterizations in common use:
1. With a shape parameter k and a scale parameter θ.
2. With a shape parameter α = k and an inverse scale parameter β = 1/θ, called a rate parameter.
3. With a shape parameter k and a mean parameter μ = k/β.
since i am not a statistician, so i will stop here leaving further theoretical part to your end! and move on to how we can solve the problems pertaining to these two distributions with MS Excel 2007.

Syntex of Gamma & Exponential Functions in Excel 2007:


= GAMMA.DIST(x,alpha,beta,cumulative)


X: Is the value at which you want to evaluate the distribution.


Alpha: A parameter to the distribution.
Beta: If beta = 1, GAMMA.DIST returns the standard gamma distribution.
Cumulative: A logical value that determines the form of the function. 

= GAMMA.INV(probability,alpha,beta)


Probability: The probability associated with the gamma distribution.
Alpha: A parameter to the distribution.
Beta: If beta = 1, GAMMA.INV returns the standard gamma distribution.

= EXPON.DIST(x,lambda,cumulative)

X: The value of the function.
Lambda: The parameter value.
Cumulative: A logical value that indicates which form of the function to provide.


Example: An engineer examines the edges of steel girders for hairline fractures. The girders are 10 m long, and it is discovered that they have an average of 42 fractures each. If a girder has 42 fractures, then there are 43 “gaps” between fractures or between the ends of the girder and the adjacent fractures. Find the probability that (a) The probability that a gap is less than 10 cm long. (b) The probability that a gap is longer than 30 cm.

Solution:  

According to this model, the length of a gap between any two adjacent fractures has an exponential distribution with λ = 4.3, the probability that a gap is less than 10 cm long is:
P(X ≤ 0.10) = F(0.10) = 1 − e−4.3×0.10 = 0.35

The probability that a gap is longer than 30 cm is:
P(X ≥ 0.30) = 1 − F(0.30) = e−4.3×0.30 = 0.28

Using Excel’s EXPONDIST() function, the solution can be reduced to:

1. =EXPONDIST(0.1,4.3,1) = 0.35
2. =1-EXPONDIST(0.3,4.3,1) = 0.28

Example: Suppose that the random variable X measures the length between one end of a girder and the fifth fracture along the girder, as shown in Figure 4.15. If the fracture locations are modeled by a Poisson process as discussed previously, X has a gamma distribution with parameters k = 5 and λ = 4.3. Find:

1. Probability that fifth fracture is at least 46 cm away from the end of the girder.
2. Probability that the fifth fracture is within 1 m of the end of the girder

Solution: 

Using Excel's GAMMADIST() function we can easily calculate this: 

1. =GAMMADIST(1,5,1/4.3,1) = 0.430
2. =GAMMADIST(0.458,5,1/4.3,1) = 0.050

You can download this file to play with it, its simple!! :)

You can use the GAMMAINV() to reverse the process. Hope you enjoy this post, please give me some feedback on contents of the Material. 

Thanks & Take Care

What's Next..Comming Attractions

Hi Readers!! How are you.

Well it has been almost three weeks since i have posted some stuff on my blog so today i thought at-least pitch a preliminary post to what i intend to write and post on. I had been too too much occupied with my office stuff and study assignment so was unable to write something but here is my plan for the rest of March, 2013:



March's Week 02: 
Hypothesis Testing for Means:

Yes this is a topic i have almost completed and need some fine tuning. Hypothesis testing for mean of  data is an introductory level topic that i will posting by the end of the second week of March. It will include demonstration problem with manual and Excel based solution as usual so do't miss it. 


March's Week 03: 
More on Statistical Distribution, Exponential & Chi-Squared.

The next in the series of Statistical Distribution are Exponential and Chi-Squared. Both of them have plenty of applications in every day life, in every field so hopefully you are going to enjoy it.


March's Week 04: 
Introduction to Calculation of Reliability with SPSS!!

Yes i am going to write for SPSS as well. You might ask why i averted from Excel to SPSS. The answer is simple. I am undertaking course in Advance Quantitative Techniques in Analysis and will be glad to share the procedures and information with you guys, so to me that is a BONUS stuff from me. 

Stay tuned and give me some feed back!!!

Thanks & Take Care! 

Understanding Negative Binomial Distribution with Excel...

in this post we are going to understand the Negative Binomial Distribution. According to Wikipedia:

"In probability theory and statistics, the negative binomial distribution is a discrete probability distribution of the number of successes in a sequence of Bernoulli trials before a specified (non-random) number of failures (denoted r) occur. For example, if we define a "1" as failure, and all non-"1"s as successes, and we throw a die repeatedly until the third time “1” appears (r = three failures), then the probability distribution of the number of non-“1”s that had appeared will be negative binomial."

The distribution can be defined by the following equation:

$$*b(x,k,p)=p^k\cdot q^{x-k}\binom{x-1}{k-1}$$ 

Here $p$ is the prbability of sucess, $k$ is the kth trial and $x$ is the number of trails.

The Excel Function that can be used for calculation of Negative Binomial Distribution is NEGBINOMDIST() that has following syntex (from the Built-in help you can find more on it!)

NEGBINOMDIST(number_f,number_s,probability_s)

..where Number_f   is the number of failures, Number_s   is the threshold number of successes, Probability_s   is the probability of a success.

Now we will take an example as-usual and will see how the manual calculation for this distribution is performed and then will move to the use of alternate excel function.

Example:

In an NBA championship series, the teams which wins four games out of seven will be the winner. Suppose that team A has probability of 0.55 of winning over the team B and both team A & B face each other in the Championship games: 

(a) What is the probability that team A will win the series in Six Games?

(b) What is the probability that team A will win the series?

(c) If both teams faces each other in a regional playoff series and the winner is decided by winning three out o f the five games, what is the probability that team A will win a Playoff?

Solution: Using the negative binomial distribution with $x=6$, $k=4$, and $p=0.55$ we get:

For (a) $*b(6,4,0.55)=\binom{5}{3}(0.55)^4(1-0.55)^2 =0.1853$

For (b) *b(4,4,0.55)+*b(5,4,0.55)+*b(6,4,0.55)+*b(7,4,0.55)

Skipping the mathematical details we can conclude it to:

$=0.0915+0.1647+0.1853+0.1668=0.6083$

For (c) *b(3,3,0.55)+*b(4,3,0.55)+*b(5,3,0.55)=0.5931

Skipping the mathematical details we can conclude it to:

$=0.1664+0.2246+0.2021=0.5931$

Alternate Solution:

Here we will see how these solutions can be obtained using NEGBINOMDIST() function:


(a) =Negbinomdist(2,4,0.55)=0.1853

(b) The probability that team A wins the series is the sum of the probabilities that matches it lost will be between zero to three (if it looses fourth match it can't win the series so the formula would be:

=Negbinomdist(3,4,0.55)+Negbinomdist(2,4,0.55)+Negbinomdist(1,4,0.55)
+Negbinomdist(0,4,0.55)

=0.1667+0.1853+0.1647+0.0915=0.6083

(c) Just like (b) the probability of a playoff for Team A is that is loosses match between 0 & 2 so the the formula will be:

=Negbinomdist(2,3,0.55)+Negbinomdist(1,3,0.55)+Negbinomdist(0,3,0.55)

=0.2021+0.2246+0.1664=0.5931 Ans.

So, that was all from me for this post, i hope you have understood the usage of Excel's built in function to facilitate the calculations. Please keep reading and give feedback to improve the block!! Take care!!

Understanding Binomial Distribution with Excel 2007

In this post we will try to understand how the Excel built-in Binomial distribution function can be used for calculating Binomial probabilities. Traditionally a binomial random variable is described by the following formula: 
$$b(x,n,p)=\binom{n}{x}p^x q^{n-x}$$

Where $p$ is the probability of success and $q$ is the probability of failure and can be related by the relation $p+q=1$, $n$ is the number of trails and $x$ is the value at which we want to evaluate the binomial probability .

The Excel 2007 has a built-in function of BINOMDIST() that takes arguments of $x,n,p$ and logical arguments for cumulative or point density estimate and return the value of Binomial Variable.

The Syntex of the function is :BINOMDIST(number_s,trials,probability_s,cum) 

Now we will see how the calculation that are done manually can be skipped if you use BINOMDIST() function, lets consider this example:

Find the probability of obtaining exactly three 2's if an ordinary dice is tossed 5 times.

Solution: The probability of success is this case is $p=\frac{1}{6},n=5,x=3$ gives:
$$b(3,5,\frac{1}{6})=\binom{5}{3}(\frac{1}{6})^{3}(\frac{5}{6})^{2}=\frac{5!}{3!2!}\cdot\frac{5!}{6!} = 0.032$$
Using Excel: The same can be calculated by  the formula: 

=Binomdist(3,5,0.1667,False)=0.032

Example # 02: The probabilities that a patient recovers from a rare blood disease is 0.4. if 15 people are known to have contracted this disease, what is the chance that (a) at lease 10 will survive (b) from 3 to 8 will survive and (c) exactly 5 will survive?

Solution: 

(a) For Probability $that at lease 10 will survive$:

$$P(x\geq 10) = 1-P(x\leq 10) = 1 - \sum_{x=0}^{9}b(x,15,0.4) = 1-0.9662 = 0.0338$$
(b) For Probability $that from 3 to 8 will survive$
$$P(3\leq x\leq8) = \sum_{x=3}^{8}b(x,15,0.4) = \sum_{x=0}^{8}b(x,15,0.4)-\sum_{x=2}^{8}b(x,15,0.4)$$
$$=0.9050-0.0271 = 0.8779$$

(c) For Probability $that exactly 5 will survive$
$$P(x = 5) = b(x,15,0.4) = \sum_{x=0}^{8}b(x,15,0.4)-\sum_{x=0}^{4}b(x,15,0.4)$$
$$=0.4032-0.02173 = 0.1859$$

Using Excel:

(a) =1-Binomdist(9,15,0.4,TRUE) = 0.0338
(b) =Binomdist(8,15,0.4,TRUE)-Binomdist(2,15,0.4,TRUE) = 0.8779
(c) =Binomdist(5,15,0.4,TRUE)-Binomdist(4,15,0.4,TRUE) = 0.1859

hence we can see how easily we can estimate the binomial probabilities using Excel 2007, I hope that you will like this post. Please give your feedback to improve the blog.

Understanding Normal Distribution with Excel 2007

Normal Distribution is most commonly used distribution. In this post we try to understand how the manual calculation of Normal distribution problems can be solved using Excel's statistical functions. Excel has following four function that are related to the distribution. 

The Normal Distribution is defined by the following equation.

$$f(x)=\frac{1}{\sigma\sqrt2\pi}e^{-\frac{(x-\mu)^2}{2\sigma^2}}$$
 

Excel 2007 Provide us with following four function related to this distribution:

1. NORMSDIST()
2. NORMSINV()
3. NORMDIST()
4. NORMINV()

Firstly we will understand what each of four stand for:

1. NORMSDIST()

This function can be used to find the value of the Z-Variable as we normally see in the Table of Z-Values. For example the value of area under the Z-Cuve for Z=0.51 is 0.6950. The Same can be found using NORMSDIST(0.51). This assume mean (
$\mu$) of zero and standard deviation ($\sigma$) of 1.

2. NORMSINV()

This function is used to find the Z-Value when we have area available to us. we can try with the value of area find in the above paragraph like NORMSINV(0.6950) that will be evaluated to 0.51. This assume mean of zero and standard deviation of 1.

3. NORMDIST()

This function takes the value of mean, st. deviation and an argument for cumulative or mass density function. If you put in one it will calculate cmulative probability and otherwise will give mass density function. 



4. NORMINV()

This function return the value of Z when you have area of the curve given in the data.

Example of Usage:

Following example elaborate the use of function. For $\mu$ = 50, $\sigma$ = 10 find the probability that x will lie between 45 and 62.

Using manual calculation we will do this:
$$Z_1=\frac{x-\mu}\sigma =  \frac{45-50}{10}=-0.5$$ and 


$$Z_2=\frac{x-\mu}\sigma =  \frac{62-50}{10}=1.2$$
Therefore the probability is ...

$$P(45<x<62)=P(-0.5<z<1.2)$$
$$=P(z<1.2)-P(z<-0.5)=0.8849-0.3085=0.5764$$
Now Using Excel 2007 formulas:
 

$$P(45<x<62)=Normdist(62,50,10,1)-Normdist(45,50,10,1)=0.5764$$
Example: Give a normal distribution with $\mu$ = 300 and $\sigma$ = 50 find the probability that $x$ assumes a value greater then 362.

Manual Working:$$Z=\frac{x-\mu}\sigma =  \frac{362-300}{50}=1.24$$ and 


$$P(x>362) = P(z>1.24) = 1-P(z>1.24)= 1-0.8925 = 0.1075$$
The Same result can be obtained using $=1-Normdist(362,300,50,1)$
 

Example No. 02 Given a normal distribution of $\mu$ = 40 and $\sigma$ = 6 find the value of x that has 45% of area below it.

The usual manual calculation for this will involve looking up value of $\phi =0.45$ in the Z-Table and substituting it in formula :$$-0.13=\frac{x-40}{6}=-0.13\times6+40\Rightarrow x=39.22$$ In this question we have been given area of the curve and we have been asked about the Z-Value itself. We will use the last function of the series that is Norminv() to calculate the value
$$P(x<Z)=0.45=Norminv(0.45,40,6)=39.24603$$This ends the tutorial for Normal Distribution, I hope that you will like it. Please give feedback to Improve the blog.

Thanks.

Understanding Hyper-geometric Distribution with excel:

Assume that a box contains 10 Plugs of which 6 are good and the rest defective. An operator picks 5 Plugs at random from the 10, and is interested in the number of good Plugs picked. 

Let X denote the number of good Plugs picked. If in a Population of size N contains S successes and (N - S ) failures, and a random sample of size n is drawn from the pool, the number of successes X in the sample follows then Hyper-geomatirc Random Variable can be defined as:

$$Hypergeomatric (x,N,n,k) = \frac{\binom{k}{x}\binom{N-k}{n-x}}{\binom{N}{n}}$$

Lets understand it with an example, for the case described in above paragraph, where N = 10, S = 6 , n = 5 , x = 2.

The Hyper-geomatric Distribution can be use to calculate the chances of getting 02 defective plugs in the sample by this:
 

$$Hypergeomatric (x,N,n,k) = \frac{\binom{5}{2}\binom{10-5}{6-2}}{\binom{10}{6}}$$ 
..This will give you exact probability of 02 Plugs.

For at most 02 Plugs i.e. at max 02 plugs will be defected:

$$Hypergeomatric (x,N,n,k) = \sum_{x=0}^{x=2}\frac{\binom{k}{x}\binom{N-k}{n-x}}{\binom{N}{n}}$$ 
 For atleast 02 Plugs i.e. at max 02 plugs will be defected:
 

$$Hypergeomatric (x,N,n,k) = 1-\sum_{x=0}^{x=2}\frac{\binom{k}{x}\binom{N-k}{n-x}}{\binom{N}{n}}$$

All this can easily be computed using
HYPGEOMDIST function of Excel. This takes follwoing arguments:   

HYPGEOMDIST(sample_s,number_sample,population_s,number_population)


Now using the Excel's Hypergeomatric Function the computation is easily done. Substituteing Values will give you the same result as you have calculated through the conventional formulas.

Hope you like this post!!

The Google Sheet Assignment - Splitting and Transposing Cell based on Delimiter - Part 1

I recently had opportunity to workout a formula with google sheets, where i realized how powerful google sheet formulas are. The problem ...