create new distribution - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Statistics : Statistics Package : Distributions : Statistics/Distribution

Statistics[Distribution] - create new distribution

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.

G:=DistributionGammaDistributiona,b

G:=moduleoptionDistribution,Continuous;exportConditions,ParentName,Parameters,CharacteristicFunction,CGF,Mean,Mode,MGF,PDF,Support,Variance,CDFNumeric,QuantileNumeric,RandomSample,RandomSampleSetup,RandomVariate,MaximumLikelihoodEstimate;end module

(1)

Y:=RandomVariableG

Y:=_R

(2)

PDFY,c

&lcub;0c<0cab1&ExponentialE;caa&Gamma;botherwise

(3)

Create a new distribution.

U:=DistributionPDF&equals;t&rarr;ft&comma;CDF&equals;t&rarr;Ft&comma;Mean&equals;3

U:=moduleoptionDistribution&comma;Continuous&semi;exportCDF&comma;Conditions&comma;PDF&comma;Mean&semi;end module

(4)

Z:=RandomVariableU

Z:=_R0

(5)

PDFZ&comma;t

ft

(6)

CDFZ&comma;t

Ft

(7)

MGFZ&comma;t

&int;&infin;&infin;&ExponentialE;_ttf_t&DifferentialD;_t

(8)

MeanZ

3

(9)

MomentZ&comma;1

3

(10)

MomentZ&comma;2

&int;&infin;&infin;_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.

myPDF:=unapplyPDFBetaDistribution1&comma;3&comma;t&comma;t

myPDF:=t&rarr;piecewiset<0&comma;0&comma;t<1&comma;31t2&comma;0

(12)

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

myCDFNumeric:=proctreturnevalfpiecewiset<0&comma;0&comma;t<1&comma;3&ast;t&ast;hypergeom&minus;2&comma;1&comma;2&comma;t&comma;1end proc

(13)

dist:=DistributionPDF&equals;myPDF&comma;CDFNumeric&equals;myCDFNumeric

dist:=moduleoptionDistribution&comma;Continuous&semi;exportCDFNumeric&comma;Conditions&comma;PDF&semi;end module

(14)

X:=RandomVariabledist

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;&apos;numeric&apos;

{--> 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

1222&sol;3&plus;1

(19)

MedianX&comma;&apos;numeric&apos;

{--> enter q, args = 0.
<-- exit q (now in brent) = 0.}
{--> enter q, args = .25
<-- exit q (now in brent) = .578124999999975}
{--> enter q, args = .25
<-- exit q (now in brent) = .578124999999975}
{--> enter q, args = 0.
<-- exit q (now in brent) = 0.}
{--> enter q, args = .25
<-- exit q (now in brent) = .578124999999975}
{--> enter q, args = .216216216216226
<-- exit q (now in brent) = .518508281839222}
{--> enter q, args = .206102270110636
<-- exit q (now in brent) = .499627215365731}
{--> enter q, args = .206301958179384
<-- exit q (now in brent) = .500004694760124}
{--> enter q, args = .206299474633007
<-- exit q (now in brent) = .50000000116623}
{--> enter q, args = .206299474015915
<-- exit q (now in brent) = .500000000000049}
{--> enter q, args = .206299474015889
<-- exit q (now in brent) = .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.

parameterizedPDF:=unapplypiecewiset<0&comma;0&comma;t<root94a&comma;3&comma;at&comma;0&comma;t

parameterizedPDF:=t&rarr;piecewiset<0&comma;0&comma;t<12181&sol;31a1&sol;3&comma;at&comma;0

(21)

parameterized:=DistributionPDF&equals;parameterizedPDF&comma;Conditions&equals;0<a

parameterized:=moduleoptionDistribution&comma;Continuous&semi;exportConditions&comma;PDF&semi;end module

(22)

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

infolevel&lsqb;Statistics&rsqb;:=2

infolevelStatistics:=2

(23)

PDFparameterized&comma;t

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

&lcub;0t<0att<12181&sol;31a1&sol;30otherwise

(24)

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

kurtosis:=Kurtosisparameterized

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

kurtosis:=1433213365032&sol;325&sol;632263182&sol;321&sol;631&sol;3354692181&sol;32125&sol;632&sol;3181&sol;3&plus;252182&sol;325231&sol;321&sol;62

(25)

simplifykurtosis

20399

(26)

The speed distribution for the molecules of an ideal gas.

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

&sigma;:=kTm

&sigma;:=k~T~m~

(27)

f:=simplifypiecewisex<0&comma;0&comma;2&pi;x2&ExponentialE;x22&sigma;2&sigma;3

f:=&lcub;0x<02m~3&sol;2x2&ExponentialE;12x2m~k~T~&pi;k~3&sol;2T~3&sol;20x

(28)

MD:=DistributionPDF&equals;unapplyf&comma;x

MD:=moduleoptionDistribution&comma;Continuous&semi;exportConditions&comma;PDF&semi;end module

(29)

Create random variable having this distribution.

X:=RandomVariableMD

X:=_R5

(30)

Compute average molecular speed.

MeanX

22k~T~&pi;m~

(31)

Compare with the Maxwell distribution.

MeanMaxwell&sigma;

22k~T~m~&pi;

(32)

Compute average kinetic energy.

simplifyExpectedValue1mX22

32k~T~

(33)

Helium at 25C.

g:=evalf&comma;T&equals;298.15&comma;k&equals;evalfScientificConstants:-Constant&apos;k&apos;&comma;m&equals;4.10-27

g:=&lcub;0x<05.40427329510-102x2&ExponentialE;4.85860393610-7x20x

(34)

&alpha;:=eval&sigma;&comma;T&equals;298.15&comma;k&equals;evalfScientificConstants:-Constant&apos;k&apos;&comma;m&equals;4.10-27

&alpha;:=1014.446746

(35)

He:=DistributionPDF&equals;unapplyg&comma;x&colon;

XHe:=RandomVariableHe&colon;

Most probable speed.

ModeXHe

1434.644346

(36)

ModeMaxwell&alpha;

1434.644346

(37)

Use simulation to verify the results.

A:=SampleXHe&comma;105&comma;method&equals;envelope&comma;range&equals;0..5000&colon;

ModeA

1432.38294579109

(38)

P:=DensityPlotXHe&comma;range&equals;0..3500&comma;thickness&equals;3&comma;color&equals;red&colon;

Q:=HistogramA&comma;range&equals;0..3500&colon;

plots&lsqb;display&rsqb;P&comma;Q

See Also

Statistics, Statistics[Computation], Statistics[Distributions], Statistics[RandomVariable]

References

  

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


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam