# How to | Work with Statistical Distributions

Statistical distributions have applications in many fields, including the biological, social, and physical sciences. The Wolfram Language represents statistical distributions as symbolic objects. You can obtain properties, results, and random numbers for hundreds of built-in or custom distributions by applying builtin functions to the objects.

Statistical distributions are simply Wolfram Language objects:

 In[1]:=
 Out[1]=

You can use the PDF function to get the probability density function for the distribution:

 In[2]:=
 Out[2]=

You can get numeric results by inserting numbers for , , and .

Compute the density for numeric values of , , and :

 In[3]:=
 Out[3]=

Symbolic results can be used in other functions as well.

Here the density function is plotted for specified values of and :

 In[4]:=
 Out[4]=

You can directly obtain common properties such as the mean, variance, cumulative distribution function (CDF), and characteristic function using builtin functions.

This is the mean for a binomial distribution for 100 trials with success probability .3:

 In[5]:=
 Out[5]=

Like a PDF, a characteristic function uniquely defines a distribution.

Obtain the general formula for the characteristic function of a Cauchy distribution:

 In[6]:=
 Out[6]=

You can also compute more general expected values, which give the value expected for a given function applied to a random variable from a given distribution. The raw moment is the expected value of raised to the power.

Obtain the raw moment for a Poisson-distributed random variable :

 In[7]:=
 Out[7]=

You can generate random numbers from distributions using RandomVariate.

These are 10 numbers simulated from a distribution with 15 degrees of freedom:

 In[8]:=
 Out[8]=

A geometric distribution describes the number of trials before a failure when there is a probability of success in each trial.

Simulate 20 numbers from a geometric distribution with success probability parameter :

 In[9]:=
 Out[9]=

You could even visualize a sample against a theoretical distribution because plots of data and functions can be combined.

Here gamma-distributed numbers are generated and stored to the symbol data:

 In[10]:=

You can use Histogram to generate a histogram of these values on a probability density scale:

 In[11]:=
 Out[11]=

You can visualize the theoretical density function using Plot:

 In[12]:=
 Out[12]=

You can then use Show to display the two graphics together:

 In[13]:=
 Out[13]=

You might also want to estimate parameter values assuming a dataset follows a particular distribution. For instance, you could find the maximum likelihood estimate for parameters by using FindDistributionParameters:

 In[14]:=
 Out[14]=

The results can be packaged up into a distribution object using EstimatedDistribution:

 In[15]:=
 Out[15]=

The loglikelihood could also be computed using LogLikelihood with the estimated distribution:

 In[16]:=
 Out[16]=

The loglikelihood value is mostly relevant compared to loglikelihood values for other parameters. Creating a ContourPlot near the obtained values can provide a qualitative comparison. Points on a given contour have the same loglikelihood.

Here a white point is placed at the optimal point:

 In[17]:=
 Out[17]=