You can define a probability object for a custom distribution and use the Distribution
Fitter app or
fitdist to fit distributions not supported
by Statistics and Machine Learning Toolbox™. You can also use a custom probability object as an input argument of
probability object functions, such as
random, to evaluate the distribution,
generate random numbers, and so on.
MATLAB® Toolstrip: On the Apps tab, under Math, Statistics and Optimization, click the app icon.
MATLAB command prompt: Enter
To define a custom distribution using the app, select File > Define Custom Distributions. A file template opens in the MATLAB Editor. You then edit this file so that it creates a probability object for the distribution you want.
The template includes sample code that defines a probability object for the Laplace distribution. Follow the instructions in the template to define your own custom distribution.
To save your custom probability object, create a directory named
your path. Save the file in this directory using a name that matches your
distribution name. For example, save the template as
LaplaceDistribution.m, and then import the custom
distribution as described in the next section.
To import a custom distribution using the app, select File > Import Custom Distributions. The Imported Distributions dialog box opens, in which you can select
the file that defines the distribution. For example, if you create the file
LaplaceDistribution.m, as described in the preceding section,
the list in the dialog box includes
Laplace followed by an
asterisk, indicating the file is new or modified and available for fitting.
Alternatively, you can use the
makedist function to reset the list of distributions so that you do
not need to select File > Import Custom Distributions in the
proband implementing classes derived from
ProbabilityDistribution. If you open the app after resetting the list, the distribution list in the app includes the custom distribution that you defined.
Once you import a custom distribution using the Distribution Fitter app or reset
the list by using
makedist, you can use the custom
distribution in the app and in the Command Window. The
Distribution field of the New Fit dialog box,
available from the Distribution Fitter app, contains the new custom distribution. In
the Command Window, you can create the custom probability distribution object by
makedist and fit a data set to the
custom distribution by using
fitdist. Then, you can use probability object functions, such as
random, to evaluate the distribution, generate random numbers, and