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

Online Help

All Products    Maple    MapleSim


Commands for Computing Properties of Random Variables

  

The Statistics package provides a wide range of tools for working with random variables. This includes tools for creating random variables from specific distributions, commands for computing basic quantities, and related functions, simulation and visualization routines.

 

Creating New Random Variables

Computing with Random Variables

Examples

Creating New Random Variables

• 

Random variables are created using the RandomVariable command.

with(Statistics):

X := RandomVariable(Normal(5, 1));

X_R

(1)

Y := RandomVariable(Normal(7, 1));

Y_R0

(2)
• 

Random variables can be distinguished from ordinary variables (names) by their attributes. Type RandomVariable can be used to query whether a given Maple object is a random variable or not.

type(X, RandomVariable);

true

(3)

type(Z, RandomVariable);

false

(4)

indets(X+Y+Z, RandomVariable);

_R,_R0

(5)

Computing with Random Variables

• 

The Statistics package provides a number of tools for computing basic quantities and functions. Single random variables as well as algebraic expressions (e.g. linear combinations, products, etc.) involving random variables are supported. Different random variables involved in an expression are considered to be independent. By default, all computations involving random variables are performed symbolically.

  

 

AbsoluteDeviation

compute the average absolute deviation

CDF

cumulative distribution function

CentralMoment

central moments

CGF

cumulant generating function

CharacteristicFunction

characteristic function

Cumulant

cumulants

CumulantGeneratingFunction

cumulant generating function

CumulativeDistributionFunction

cumulative distribution function

Decile

deciles

ExpectedValue

compute expected values

FailureRate

hazard (failure) rate

GeometricMean

geometric mean

HarmonicMean

harmonic mean

HazardRate

hazard (failure) rate

HodgesLehmann

Hodges-Lehmann statistic

InterquartileRange

interquartile range

InverseSurvivalFunction

inverse survival function

Kurtosis

kurtosis

MakeProcedure

generate a procedure for calculating statistical quantities

Mean

arithmetic mean

MeanDeviation

average absolute deviation from the mean

Median

median

MedianDeviation

compute the median absolute deviation

MGF

moment generating function

MillsRatio

Mills ratio

Mode

mode

Moment

moments

MomentGeneratingFunction

moment generating function

OrderStatistic

order statistics

PDF

probability density function

Percentile

percentiles

Probability

compute the probability of an event

ProbabilityDensityFunction

probability density function

ProbabilityFunction

probability function

QuadraticMean

quadratic mean

Quantile

quantiles

Quartile

quartiles

RandomVariable

create new random variables

RousseeuwCrouxQn

Rousseeuw and Croux' Qn

RousseeuwCrouxSn

Rousseeuw and Croux' Sn

Skewness

skewness

StandardDeviation

standard deviation

StandardError

standard error of the sampling distribution

StandardizedMoment

standardized moments

Support

support set of a random variable

SurvivalFunction

survival function

Variance

variance

Variation

coefficient of variation

Examples

withStatistics:

Compute the PDF and the CDF of the non-central beta distribution.

PDFNonCentralBeta5,3,m,t

0t<0&ExponentialE;m2t41t2116m3t3+218m2t2+632mt+105&ExponentialE;mt2t10otherwise

(6)

CDFNonCentralBeta5&comma;3&comma;m&comma;t

0t0t5&ExponentialE;12m+12mtm2t42m2t3+m2t2+24mt352mt2+28mt+120t2280t+1688t111<t

(7)

Compute the PDF, mean, standard deviation and moments of a Beta random variable.

XRandomVariableΒp&comma;q

X_R3

(8)

PDFX&comma;t

0t<0tp11tq1Βp&comma;qt<10otherwise

(9)

MeanX

pp+q

(10)

StandardDeviationX

pqp+q+1p+q

(11)

MomentX&comma;n

Βq&comma;n+pΒp&comma;q

(12)

Create two normal random variables.

XRandomVariableNormal0&comma;1

X_R4

(13)

YRandomVariableNormal0&comma;1

Y_R5

(14)

Compute the density of X/Y. Compare the result with the Cauchy density.

PDFXY&comma;t

1t2+1π

(15)

PDFCauchy0&comma;1&comma;t

1t2+1π

(16)

Compute some probabilities.

XRandomVariableNormal0&comma;1&colon;

ProbabilityX2<X

erf222

(17)

The speed distribution for the molecules of an ideal gas.

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

σsqrtkTm

σk~T~m~

(18)

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

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

(19)

MDDistributionPDF=unapplyf&comma;x

MDmoduleoptionDistribution&comma;Continuous&semi;exportPDF&comma;Conditions&semi;end module

(20)

Create random variable having this distribution.

XRandomVariableMD

X_R8

(21)

Compute average molecular speed.

MeanX

2T~k~2m~π

(22)

Compute average kinetic energy.

simplifyExpectedValue12mX2

3k~T~2

(23)

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

(24)

HeDistributionPDF=unapplyg&comma;x&colon;

XHeRandomVariableHe&colon;

Most probable speed.

ModeXHe

1434.643427

(25)

Use simulation to verify the results.

ASampleXHe&comma;105

ModeA

1444.17684604007

(26)

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

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

plotsdisplayP&comma;Q

See Also

Statistics

Statistics[Computation]

Statistics[DescriptiveStatistics]

Statistics[Distributions]

Statistics[Simulation]