And now, Exponential distribution
When probability modeling, you will not be using the probability distributions superclass directly. Instead, you will be interacting with specific instantiations of the probability distributions superclass, one for each common probability distribution for which analytic work has been done to figure out how to implement the PDF, CDF, InverseCDF, and RNG methods.
R, for example, includes such methods for all of these univariate distributions:
- Chi Square
- Negative Binomial
- Student's t
As you can see, when it comes to fitting the probability distribution for your random variable to a specific theoretical probability distribution, you can choose from many such distributions. For you to become proficient in basic probability modeling, you need to become familiar with:
- The visual representation of such distributions
- The shape and location adjustment parameters that most probability distributions accept
- Which adjustment parameters are used for model fitting
Statistics textbooks and Web sites can be consulted for these details. See Resources.
I want to focus on one particular probability distribution called the exponential distribution. What you learn from this example can be used to understand how to use other probability distributions to construct univariate probability models.
The exponential distribution in particular possesses these four advantages:
- The implementation of the distribution function methods can be easily found in textbooks or online so that you can see where they came from. Many math books focus on using positive and negative exponential functions to model change in some variable (for example, balance) as a function of time (for example, term interest rate).
- The exponential distribution can be used to construct basic probability models (such as assigning probabilities to various statements about a random variable) for the behavior of a large number of phenomenon (for example, random variables of interest). It is commonly used to model the distribution of waiting times -- either the time elapsed until some event occurs or the interval between each occurrence of an event. I will illustrate such an application in the next section.
- Textbooks on applied probability modeling often focus on the Exponential and Poisson distributions in particular because together they have demonstrated general utility and can be used to construct more elaborate probability models. In other words, not all probability distributions are equivalent in terms of their usefulness in modeling a variety of real-world phenomenon. The Exponential and Poisson distributions in particular are extremely useful for applied, real-world probability modeling. The Uniform, Normal and Binomial probability distributions are three other distributions you should make an effort to study in detail.
- When the observed distribution of your random variable is exponentially distributed, understanding the likelihood of different outcomes is much harder to do by intuition, so it helps in these cases especially to have a formal probability model for the random variable.
Start looking at the Exponential distribution by seeing some examples. The shape and location aspects of the Exponential distribution are determined by a single parameter called lambda (, also known as the rate or decay parameter). Figure 6 plots the probability distributions for four different values of lambda.
Listing 4 is the code that implements the probability distribution
methods for an Exponential distribution. Notice that the PDF method
returns probability values for given values of X; this information was
used to construct the lines in Figure 6. Also notice that the core
distribution methods (
return a single answer or a vector of answers depending on how the
method is called. This feature will be demonstrated later in a script
that tests the methods of this class.
To gain insight into how this class is used and what it does, I have created a script in the tests directory of the accompanying
PHPMath_ProbabilityDistribution package that demonstrates usage and method-return values. The script is called exponential.php and looks like this:
The exponential.php test script generates five HTML tables.
Table 2 demonstrates the single values that all the methods in the
class can return. You can verify that these methods are producing
accurate results by comparing their output to what a more mature
statistical computing environment like R would generate (for an
example, revisit the
Table 2. Single values all methods in Exponential.php returns
|Exponential Distribution (lambda=1)|
You can also use these tables to assist you in understanding the types of values the functions return when passed different arguments. Tables 3, 4, and 5 are particularly useful for this. They illustrate the vector orientation of these methods and consequently allow you to see the behavior of the three major distribution functions (PDF, CDF, and InverseCDF) over a range of input values (when lambda is set to 1).
|X Vals Input||P Vals Output|
|X Vals Input||P Vals Output|
|P Vals Input||X Vals Output|
Table 6 displays output from the random-number generator. The
method generates exponentially distributed random numbers using the
value of lambda to adjust the shape and location aspects of the
exponential distribution you are sampling from.
Table 6. Output from the random-number generator