Commands for Computing Properties of Random Variables - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Statistics and Data Analysis : Statistics Package : Random Variables : Statistics/RandomVariables

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

&lcub;0t<0&ExponentialE;12mt41t2&ExponentialE;12mt116m3t3&plus;218m2t2&plus;632mt&plus;105t10otherwise

(6)

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

&lcub;0t018m2t42m2t3&plus;m2t2&plus;24mt352mt2&plus;28mt&plus;120t2280t&plus;168t5&ExponentialE;12m&plus;12mtt111<t

(7)

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

XRandomVariable&Beta;p&comma;q

X:=_R3

(8)

PDFX&comma;t

&lcub;0t<0t1&plus;p1t1&plus;q&Beta;p&comma;qt<10otherwise

(9)

MeanX

pp&plus;q

(10)

StandardDeviationX

pqp&plus;q&plus;1p&plus;q

(11)

MomentX&comma;n

&Gamma;1&plus;n&plus;p&Gamma;q&Gamma;n&plus;p&plus;q&Beta;p&comma;qn&plus;p

(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&plus;1&pi;

(15)

PDFCauchy0&comma;1&comma;t

1t2&plus;1&pi;

(16)

Compute some probabilities.

XRandomVariableNormal0&comma;1&colon;

ProbabilityX2<X

12erf122

(17)

The speed distribution for the molecules of an ideal gas.

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

&sigma;kTm

&sigma;:=k~T~m~

(18)

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

(19)

MDDistributionPDF&equals;unapplyf&comma;x

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

(20)

Create random variable having this distribution.

XRandomVariableMD

X:=_R8

(21)

Compute average molecular speed.

MeanX

22k~T~&pi;m~

(22)

Compute average kinetic energy.

simplifyExpectedValue1mX22

32k~T~

(23)

Helium at 25C.

gevalf&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

(24)

HeDistributionPDF&equals;unapplyg&comma;x&colon;

XHeRandomVariableHe&colon;

Most probable speed.

ModeXHe

1434.644346

(25)

Use simulation to verify the results.

ASampleXHe&comma;105

A:= 1 .. 100000 VectorrowData Type: float8Storage: rectangularOrder: Fortran_order

(26)

ModeA

1499.36185224997

(27)

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

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

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

See Also

Statistics

Statistics[Computation]

Statistics[DescriptiveStatistics]

Statistics[Distributions]

Statistics[Simulation]

 


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