Student[Statistics] - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Education : Student Package : Statistics : Student/Statistics/Sample

Student[Statistics]

  

Sample

  

generate random sample

 

Calling Sequence

Parameters

Description

Computation

Examples

References

Compatibility

Calling Sequence

Sample(X, n, numeric_option, output_option)

Parameters

X

-

algebraic; random variable

n

-

positive integer; sample size

numeric_option

-

(optional) equation of the form numeric=value where value is true or false

output_option

-

(optional) equation of the form output=x where x is value, plot, or both

Description

• 

The Sample command generates a random sample drawn from the distribution given by X.

• 

The first parameter, X, can be a random variable, or an algebraic expression involving random variables (see Student[Statistics][RandomVariable]).

• 

The second parameter, n, is the sample size. The function will return a newly created Vector of length n, filled with the sample values.

• 

If the option output is not included or is specified to be output=value, then the function will return the generated sample as a Vector. If output=plot is specified, then the function will return a density plot of the input random variable together with a histogram of the sample. If output=both is specified, then both the value and the plot will be returned.

Computation

• 

If X is a continuous random variable, or an expression that contains a floating point value, or an expression that contains a continuous random variable, then the sample is returned as floating point values. Otherwise, the sample is returned as exact values.

• 

By default, the data are generated according to the rule above. To always generate data numerically, specify the numeric or numeric=true option.

Examples

withStudent[Statistics]:

Straightforward sampling of a random variable.

XNormalRandomVariable0,1

X_R

(1)

ASampleX,10

A1.072424127998270.3290778705470650.6170919369097900.2144667452452910.02542812804238461.728821284177831.634856754343901.571172171754300.1703584214104081.00647840875181

(2)

You can check how well the generated data fit the input model by specifying the output=plot option and comparing the their graphs.

SampleX,105,output=plot

You can also sample an expression involving two random variables.

YNormalRandomVariable0,1

Y_R0

(3)

SampleⅇXY,10

0.2537355200466833.232293062020390.1129797543361500.1574827847859360.12249259366914319.60719367534151.352293325253040.07322767556939012.209153842208710.189083076767802

(4)

Consider a discrete random variable.

BPoissonRandomVariable3

B_R1

(5)

SampleBπ,10

4π3π2π5π3π5π1π2π2π4π

(6)

To always generate floating point value data, specify the numeric or numeric=true option.

SampleBπ,10,numeric

0.9549296585513721.273239544735161.273239544735161.273239544735160.6366197723675812.228169203286540.6366197723675810.3183098861837910.3183098861837911.27323954473516

(7)

Use the output=both option to obtain both the value and plot of the generated data.

dataset,graphSampleB,100,output=both

dataset,graph 1 .. 100 VectorrowData Type: anythingStorage: rectangularOrder: Fortran_order,

dataset

1 .. 100 VectorrowData Type: anythingStorage: rectangularOrder: Fortran_order

(8)

graph

You can also compute the statistics of the generated data.

CSampleX2,104

C 1 .. 10000 VectorrowData Type: float8Storage: rectangularOrder: Fortran_order

(9)

MeanC

0.990673425318131

(10)

MedianC

0.453986354979151

(11)

SkewnessC

2.77883456642836

(12)

KurtosisC

14.4546978275010

(13)

VarianceC

1.93714365220748

(14)

StandardDeviationC

1.39181308091549

(15)

QuantileC,0.6

0.710679651989900

(16)

References

  

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

  

Walker, Alastair J. New Fast Method for Generating Discrete Random Numbers with Arbitrary Frequency Distributions, Electronic Letters, 10, 127-128.

  

Walker, Alastair J. An Efficient Method for Generating Discrete Random Variables with General Distributions, ACM Trans. Math. Software, 3, 253-256.

Compatibility

• 

The Student[Statistics][Sample] command was introduced in Maple 18.

• 

For more information on Maple 18 changes, see Updates in Maple 18.

See Also

Statistics[Sample]

Student

Student[Statistics]

Student[Statistics][RandomVariable]