MATLAB Examples

Compute and plot the pdf of a Poisson distribution with parameter lambda = 5 .

Use copulafit to calibrate copulas with data. To generate data Xsim with a distribution "just like" (in terms of marginal distributions and correlations) the distribution of data in the

Similar to the bootstrap is the jackknife, which uses resampling to estimate the bias of a sample statistic. Sometimes it is also used to estimate standard error of the sample statistic. The

Plot the pdf of a bivariate Student's t distribution. You can use this distribution for a higher number of dimensions as well, although visualization is not easy.

Compute and plot the pdf using four different values for the parameter r , the desired number of successes: .1 , 1 , 3 , and 6 . In each case, the probability of success p is .5 .

As for all discrete distributions, the cdf is a step function. The plot shows the discrete uniform cdf for N = 10.

Compute and plot the pdf of a multivariate normal distribution.

The bootstrap procedure involves choosing random samples with replacement from a data set and analyzing each sample the same way. Sampling with replacement means that each observation is

Compute the pdf of an F distribution with 5 numerator degrees of freedom and 3 denominator degrees of freedom.

Compute the pdf of a gamma distribution with parameters A = 100 and B = 10 . For comparison, also compute the pdf of a normal distribution with parameters mu = 1000 and sigma = 100 .

Compute the pdf of an exponential distribution with parameter mu = 2 .

Pick a random sample of 10 from a list of 553 items.

Suppose the income of a family of four in the United States follows a lognormal distribution with mu = log(20,000) and sigma = 1 . Compute and plot the income density.

Compute the pdf for a Student's t distribution with parameter nu = 5 , and for a standard normal distribution.

Compute the pdf of a chi-square distribution with 4 degrees of freedom.

Compute and plot the cdf of a hypergeometric distribution.

Since the bivariate normal distribution is defined on the plane, you can also compute cumulative probabilities over rectangular regions.

Generate examples of probability density functions for the three basic forms of the generalized extreme value distribution.

Suppose the probability of a five-year-old car battery not starting in cold weather is 0.03. What is the probability of the car starting for 25 consecutive days during a long cold snap?

Compute the pdf of an extreme value distribution.

Use haltonset to construct a 2-D Halton quasi-random point set.

Compute the pdf of three generalized Pareto distributions. The first has shape parameter k = -0.25 , the second has k = 0 , and the third has k = 1 .

The lognrnd function simulates independent lognormal random variables. In the following example, the mvnrnd function generates n pairs of independent normal random variables, and then

Compute the pdf of a standard normal distribution, with parameters \mu equal to 0 and \sigma equal to 1.

Gaussian mixture models (GMM) are often used for data clustering. Usually, fitted GMMs cluster by assigning query data points to the multivariate normal components that maximize the

Generate samples from a quasi-random point set.

Simulate data from a multivariate normal distribution, and then fit a Gaussian mixture model (GMM) to the data using fitgmdist . To create a known, or fully specified, GMM object, see Create

Implement soft clustering on simulated data from a mixture of Gaussian distributions.

Create a known, or fully specified, Gaussian mixture model (GMM) object using gmdistribution and by specifying component means, covariances, and mixture proportions. To create a GMM

Implement hard clustering on simulated data from a mixture of Gaussian distributions.

Determine the best Gaussian mixture model (GMM) fit by adjusting the number of components and the component covariance matrix structure.

Simulate data from a Gaussian mixture model (GMM) using a fully specified gmdistribution object and the random function.

Estimate the cumulative distribution function (CDF) from data in a nonparametric or semiparametric way. It also illustrates the inversion method for generating random numbers from the

The following plot compares the probability density functions for the standard normal, Cauchy, and Lévy distributions.

How changing the values of the mu and sigma parameters alters the shape of the pdf.

The following plot compares the probability density functions for stable distributions with different alpha values. In each case, beta = 0 , gam = 1 , and delta = 0 .

Fit a Burr distribution to data, draw the cdf, and construct a histogram with a Burr distribution fit.

Use some more advanced techniques with the Statistics and Machine Learning Toolbox™ function mle to fit custom distributions to univariate data. The techniques include fitting models to

Fit the generalized extreme value distribution using maximum likelihood estimation. The extreme value distribution is used to model the largest or smallest value from a group or block of

The difference between fitting a curve to a set of points, and fitting a probability distribution to a sample of data.

Use copulas to generate data from multivariate distributions when there are complicated relationships among the variables, or when the individual variables are from different

Use the Statistics and Machine Learning Toolbox™ function mle to fit custom distributions to univariate data.

Find and plot the survival and hazard functions for a sample coming from a Burr distribution.

The following plot compares the cumulative distribution functions for stable distributions with different alpha values. In each case, beta = 0 , gam = 1 , and delta = 0 .

How changing the values of the mu and sigma parameters alters the shape of the cdf.

Create a variety of shapes for probability density functions of the Burr distribution.

Compare the lognormal pdf to the Burr pdf using income data generated from a lognormal distribution.

Analyze lifetime data with censoring. In biological or medical applications, this is known as survival analysis, and the times may represent the survival time of an organism or the time

Fit tail data to the Generalized Pareto distribution by maximum likelihood estimation.

Fit univariate distributions using least squares estimates of the cumulative distribution functions. This is a generally-applicable method that can be useful in cases when maximum

The functional form of some distributions makes it difficult or time-consuming to generate random numbers using direct or inversion methods. Acceptance-rejection methods provide an

The exponential distribution has a constant hazard function, which is not generally the case for the Weibull distribution. The plot shows the hazard function for exponential (dashed line)

Generate random numbers and compute and plot the pdf of a multinomial distribution using probability distribution functions.

Use the t location-scale probability distribution object to work with a Cauchy distribution with nonstandard parameter values.

Suppose you want to model the tensile strength of a thin filament using the Weibull distribution. The function wblfit gives maximum likelihood estimates and confidence intervals for the

Use the Student's t distribution to generate random numbers from a standard Cauchy distribution.

Generate random numbers using the uniform distribution inversion method. This is useful for distributions when it is possible to compute the inverse cumulative distribution function,

The mle function computes maximum likelihood estimates (MLEs) for a distribution specified by its name and for a custom distribution specified by its probability density function (pdf),

Use a copula and rank correlation to generate correlated data from probability distributions that do not have an inverse cdf function available, such as the Pearson flexible distribution

Create a triangular probability distribution object based on sample data, and generate random numbers for use in a simulation.

Find MLEs by using the gamlike and fminsearch functions.

Fit multiple probability distribution objects to the same set of sample data, and obtain a visual comparison of how well each distribution fits the data.

Generate a kernel probability density estimate from sample data using the ksdensity function.

Fit a nonparametric probability distribution to sample data using Pareto tails to smooth the distribution in the tails.

Use probability distribution objects to perform a multistep analysis on a fitted distribution.

Fit a kernel probability distribution object to sample data.

Direct methods directly use the definition of the distribution.

Perform Bayesian inference on a linear regression model using a Hamiltonian Monte Carlo (HMC) sampler.

Fit kernel distributions to grouped sample data using the ksdensity function.

Inversion methods are based on the observation that continuous cumulative distribution functions (cdfs) range uniformly over the interval (0,1). If is a uniform random number on (0,1),

Estimate parameters of a three-parameter Weibull distribution by using a custom probability density function.

Generate data using the Pearson and Johnson systems of distributions.

Use the probability distribution function normcdf as a function handle in the chi-square goodness of fit test ( chi2gof ).

Fit probability distribution objects to grouped sample data, and create a plot to visually compare the pdf of each group.

Generate random numbers, compute and plot the pdf, and compute descriptive statistics of a multinomial distribution using probability distribution objects.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Contact your local office