Create a Custom Distribution - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Statistics

  

Distribution

  

create new distribution

 

Calling Sequence

Parameters

Description

Examples

References

Compatibility

Calling Sequence

Distribution(D)

Distribution(T1, T2, .., Tn)

Parameters

D

-

ProbabilityDistribution; built-in probability distribution

Ti

-

Equation; function or quantity of the new distribution, including PDF, CDF, mean, moment, variance, and others

Description

• 

The Distribution command creates a new distribution with the specified distribution, functions, or quantities.

• 

The first parameter can be one of the supported distributions or a distribution function or quantity.

• 

A distribution can be defined by the following functions and quantities. The other functions and quantities are calculated if possible.  If not specified otherwise, the default value for all of these functions and quantities is FAIL, indicating that this quantity needs to be computed from others.

– 

CDF - operator

  

Operator mapping a value t to the CDF of this distribution at t.

– 

CDFNumeric - appliable

  

Procedure for efficiently computing a floating-point approximation to the CDF.

– 

CentralMoment - operator

  

Operator mapping a positive integer n to the nth CentralMoment of this distribution.

– 

CFNumeric - appliable

  

Procedure for efficiently computing a floating-point approximation to the CharacteristicFunction.

– 

CGF - operator

  

Operator mapping a value t to the CGF of this distribution at t.

– 

CGFNumeric - appliable

  

Procedure for efficiently computing a floating-point approximation to the CGF.

– 

CharacteristicFunction - operator

  

Operator mapping a value t to the CharacteristicFunction of this distribution at t.

– 

Conditions - list(boolean)

  

List of conditions on parameters occurring in the other defining equations for this distribution. The conditions need to be satisfied for the distribution to be valid. If the conditions are at any point known not to be satisfied, an error is raised; otherwise, the conditions are implicitly assumed to be satisfied. For this quantity, the default value is the empty list, []; you cannot specify FAIL.

  

If infolevel for Statistics is set to at least 2, the implicit assumptions are printed when they are made.

– 

Cumulant - operator

  

Operator mapping a positive integer n to the nth Cumulant of this distribution.

– 

DiscreteValueMap - operator

  

See the DiscreteValueMap help page.

– 

HazardRate - operator

  

Operator mapping a value t to the HazardRate of this distribution at t.

– 

HodgesLehmann - algebraic

  

Expression giving the Hodges-Lehmann estimator of this distribution.

– 

InverseSurvivalFunction - operator

  

Operator mapping a value t to the InverseSurvivalFunction of this distribution at t.

– 

ISFNumeric - appliable

  

Procedure for efficiently computing a floating-point approximation to the InverseSurvivalFunction.

– 

Kurtosis - algebraic

  

Expression giving the Kurtosis of this distribution.

– 

Mean - algebraic

  

Expression giving the Mean of this distribution.

– 

Median - algebraic

  

Expression giving the Median of this distribution.

– 

MGF - operator

  

Operator mapping a value t to the MGF of this distribution at t.

– 

MGFNumeric - appliable

  

Procedure for efficiently computing a floating-point approximation to the MGF.

– 

MillsRatio - operator

  

Operator mapping a value t to the MillsRatio of this distribution at t.

– 

Mode - algebraic

  

Expression giving the Mode of this distribution.

– 

Moment - operator

  

Operator mapping a positive integer n to the nth Moment of this distribution.

– 

PDF - operator

  

Operator mapping a value t to the PDF of this distribution at t.

– 

PDFNumeric - appliable

  

Procedure for efficiently computing a floating-point approximation to the PDF.

– 

PFNumeric - appliable

  

Procedure for efficiently computing a floating-point approximation to the ProbabilityFunction.

– 

ProbabilityFunction - operator

  

Operator mapping a value t to the ProbabilityFunction of this distribution at t.

– 

Quantile - operator

  

Operator mapping a value t between 0 and 1 to the tth Quantile of this distribution.

– 

QuantileNumeric - appliable

  

Procedure for efficiently computing a floating-point approximation to the Quantile.

– 

RandomSample - appliable

  

Procedure for efficiently computing a random sample of this distribution. The procedure should accept all of the calling sequences that Sample accepts:

• 

When called with a non-negative integer argument n, the procedure should return the sample as a Vector of length n having datatype = float.

• 

When called with an integer range or a list of integer ranges, the procedure should return the sample as an Array with those dimensions having datatype = float.

• 

When called with any rtable having datatype = float, the procedure should return the sample in that rtable.

– 

RousseeuwCrouxQn - algebraic

  

Expression giving Rousseeuw and Croux' Qn of this distribution.

– 

RousseeuwCrouxSn - algebraic

  

Expression giving Rousseeuw and Croux' Sn of this distribution.

– 

Skewness - algebraic

  

Expression giving the Skewness of this distribution.

– 

Specialize - appliable

  

Procedure returning the distribution that Specialize of this distribution will return. The procedure should take a list of equations as its single argument, and return a new distribution data structure; the most convenient way to produce one is to call Distribution itself.

– 

StandardDeviation - algebraic

  

Expression giving the StandardDeviation of this distribution.

– 

StandardizedMoment - operator

  

Operator mapping a positive integer n to the nth StandardizedMoment of this distribution.

– 

SFNumeric - appliable

  

Procedure for efficiently computing the SurvivalFunction of this distribution.

– 

Support - algebraic .. algebraic

  

Range containing the Support of this distribution. If a DiscreteValueMap is specified, then this should be the support in the source domain. See the DiscreteValueMap help page for more details. If the Support is not given explicitly, an attempt is made to infer the Support from the PDF or the ProbabilityFunction, falling back to the default value of .. if this attempt fails.

– 

SurvivalFunction - operator

  

Operator mapping a value t to the SurvivalFunction of this distribution at t.

– 

Type - equal to either discrete or continuous

  

Indicates whether the distribution is discrete (meaning it can only assume finitely or countably many values, each with positive probability) or continuous (meaning the probability for it to assume any particular value is 0). The default value for this property is continuous; it cannot be FAIL. For discrete distributions that can assume non-integer values, you will need to specify a DiscreteValueMap. See the DiscreteValueMap help page for more details.

– 

Variance - algebraic

  

Expression giving the Variance of this distribution.

Examples

withStatistics:

Create a Gamma distribution.

GDistributionGammaDistributiona,b

GmoduleoptionDistribution,Continuous;exportConditions,Dimensions,ParentName,Parameters,CharacteristicFunction,CGF,Mean,Mode,MGF,PDF,Support,Variance,CDFNumeric,QuantileNumeric,RandomSample,RandomSampleSetup,RandomVariate,MaximumLikelihoodEstimate;end module

(1)

YRandomVariableG

Y_R

(2)

PDFY,c

0c<0cab1&ExponentialE;caaΓbotherwise

(3)

Create a new distribution.

UDistribution`=`PDF&comma;tft&comma;`=`CDF&comma;tFt&comma;Mean=3

UmoduleoptionDistribution&comma;Continuous&semi;exportCDF&comma;Conditions&comma;PDF&comma;Mean&semi;end module

(4)

ZRandomVariableU

Z_R0

(5)

PDFZ&comma;t

ft

(6)

CDFZ&comma;t

Ft

(7)

MGFZ&comma;t

&ExponentialE;_ttf_t&DifferentialD;_t

(8)

MeanZ

3

(9)

MomentZ&comma;1

3

(10)

MomentZ&comma;2

_t02f_t0&DifferentialD;_t0

(11)

The following is effectively a reimplementation of the BetaDistribution with parameters 1 and 3. We reimplement the numeric CDF procedure, so that we can call trace in order to see when it is used.

myPDFunapplyPDFBetaDistribution1&comma;3&comma;t&comma;t

myPDFt0t<031t2t<10otherwise

(12)

myCDFNumeric := proc(t)
 return evalf(piecewise(t<0, 0, t<1, 3*t*hypergeom([-2, 1], [2], t), 1));
end proc;
trace(myCDFNumeric):

myCDFNumericproctreturnevalfpiecewiset<0&comma;0&comma;t<1&comma;3&ast;t&ast;hypergeom&minus;2&comma;1&comma;2&comma;t&comma;1end proc

(13)

distDistributionPDF=myPDF&comma;CDFNumeric=myCDFNumeric

distmoduleoptionDistribution&comma;Continuous&semi;exportConditions&comma;CDFNumeric&comma;PDF&semi;end module

(14)

XRandomVariabledist

X_R2

(15)

This does not call the numeric CDF procedure - only the regular one (which in this case integrates the PDF expression symbolically):

CDFX&comma;12

78

(16)

But these calling sequences do lead to a call to myCDFNumeric:

CDFX&comma;0.5

{--> enter q, args = .5
<-- exit q (now in GetValue) = .8749999998}

0.8749999998

(17)

CDFX&comma;12&comma;numeric

{--> enter q, args = 1/2
<-- exit q (now in GetValue) = .8750000000}

0.8750000000

(18)

For Median, it also depends on the numeric option (coincidentally, this call runs via Quantile):

MedianX

2232+1

(19)

MedianX&comma;numeric

{--> enter q, args = 0.
<-- exit q (now in extproc) = 0.}
{--> enter q, args = .25
<-- exit q (now in extproc) = .578124999999975}
{--> enter q, args = .25
<-- exit q (now in extproc) = .578124999999975}
{--> enter q, args = 0.
<-- exit q (now in extproc) = 0.}
{--> enter q, args = .25
<-- exit q (now in extproc) = .578124999999975}
{--> enter q, args = .216216216216226
<-- exit q (now in extproc) = .518508281839222}
{--> enter q, args = .206102270110636
<-- exit q (now in extproc) = .499627215365731}
{--> enter q, args = .206301958179384
<-- exit q (now in extproc) = .500004694760124}
{--> enter q, args = .206299474633007
<-- exit q (now in extproc) = .50000000116623}
{--> enter q, args = .206299474015915
<-- exit q (now in extproc) = .500000000000049}
{--> enter q, args = .206299474015889
<-- exit q (now in extproc) = .499999999999986}

0.206299474015889

(20)

We create a parameterized distribution with PDF at at appropriate values t. The parameter a must be a positive real number.

parameterizedPDFunapplypiecewiset<0&comma;0&comma;t<root94a&comma;3&comma;sqrtat&comma;0&comma;t

parameterizedPDFt0t<0att<18131a1320otherwise

(21)

parameterizedDistributionPDF=parameterizedPDF&comma;Conditions=0<a

parameterizedmoduleoptionDistribution&comma;Continuous&semi;exportConditions&comma;PDF&semi;end module

(22)

By setting infolevel, we can see when these assumptions are used.

infolevelStatistics2

infolevelStatistics2

(23)

PDFparameterized&comma;t

Statistics:-PDF -- using the following implicit assumptions: {0 < a}

0t<0att<18131a1320otherwise

(24)

It turns out that the Kurtosis of this distribution is independent of a.

kurtosisKurtosisparameterized

Statistics:-Kurtosis -- using the following implicit assumptions: {0 < a}

kurtosis141228721332311823181311632233132518232

(25)

simplifykurtosis

20399

(26)

The speed distribution for the molecules of an ideal gas.

assume0<m&comma;0<k&comma;0<T

σsqrtkTm

σk~T~m~

(27)

fsimplifypiecewisex<0&comma;0&comma;sqrt2πσ3x2expx22σ2

f0x<02m~32x2&ExponentialE;x2m~2k~T~πk~32T~320x

(28)

MDDistributionPDF=unapplyf&comma;x

MDmoduleoptionDistribution&comma;Continuous&semi;exportConditions&comma;PDF&semi;end module

(29)

Create random variable having this distribution.

XRandomVariableMD

X_R5

(30)

Compute average molecular speed.

MeanX

2T~k~2m~π

(31)

Compare with the Maxwell distribution.

MeanMaxwellσ

22k~T~m~π

(32)

Compute average kinetic energy.

simplifyExpectedValue12mX2

3k~T~2

(33)

Helium at 25C.

gevalf&comma;T=298.15&comma;k=evalfScientificConstants:-Constantk&comma;m=4.×10−27

g0x<05.404283672×10−102x2&ExponentialE;4.858610154×10−7x20x

(34)

αevalσ&comma;T=298.15&comma;k=evalfScientificConstants:-Constantk&comma;m=4.×10−27

α1014.446097

(35)

HeDistributionPDF=unapplyg&comma;x&colon;

XHeRandomVariableHe&colon;

Most probable speed.

ModeXHe

1434.643427

(36)

ModeMaxwellα

1434.643428

(37)

Use simulation to verify the results.

ASampleXHe&comma;105&comma;method=envelope&comma;range=0..5000&colon;

ModeA

1479.23422185382

(38)

PDensityPlotXHe&comma;range=0..3500&comma;thickness=3&comma;color=red&colon;

QHistogramA&comma;range=0..3500&colon;

plotsdisplayP&comma;Q

References

  

Stuart, Alan, and Ord, Keith. Kendall's Advanced Theory of Statistics. 6th ed. London: Edward Arnold, 1998. Vol. 1: Distribution Theory.

Compatibility

• 

The Statistics[Distribution] command was updated in Maple 16.

See Also

Statistics

Statistics[Computation]

Statistics[Distributions]

Statistics[RandomVariable]