The Student Statistics Package - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

The Student Statistics Package

Description

The Student[Statistics] subpackage is designed to help teachers present and students understand the basic material of a standard course in statistics.

Getting Started

While any command in the package can be referred to using the long form, for example, Student[Statistics][NormalRandomVariable], it is often easier to load the package and then use the short form command names.

restart;

with(Student[Statistics]):

Quantities

A := BinomialRandomVariable(5, 1/3):

Probability({A>=2, A<=4});

130243

(1)

Mean(A);

53

(2)

Correlation(A, A^2);

111370101370

(3)

M := Matrix([[1,2,4,1],[2,4,1,2],[6,5,2,7],[1,2,0,9]]);

M:=1241241265271209

(4)

Variance(M);

17394351217912

(5)

L := [1, 2, 3, 1, 2, 3, 1, 2, 2, 2, 6, 2, 3, 4, 5, 2, 4]:

Mode(L);

2

(6)

Percentile(L, 30);

2

(7)

Formulas

B := NormalRandomVariable(1,2):

Probability(B<x, inert);

&int;&infin;x142&ExponentialE;18_t212&pi;&DifferentialD;_t2

(8)

CumulativeDistributionFunction(B, 3, output=plot);

Hypothesis Testing

X := [6, 3, 2, 1, 9, 1, 2, 3, 3, 2]:

StandardDeviation(X);

1151390

(9)

ChiSquareSuitableModelTest(X, PoissonRandomVariable(3));

Chi-Square Test for Suitable Probability Model

----------------------------------------------
Null Hypothesis:
Sample was drawn from specified probability distribution
Alt. Hypothesis:
Sample was not drawn from specified probability distribution
Bins:                    5
Degrees of freedom:      4
Distribution:            ChiSquare(4)
Computed statistic:      2.20801
Computed pvalue:         0.697563
Critical value:          9.48772903678116
Result: [Accepted]
There is no statistical evidence against the null hypothesis

hypothesis&equals;true&comma;criticalvalue&equals;9.48772903678116&comma;distribution&equals;ChiSquare4&comma;pvalue&equals;0.697562873819393&comma;statistic&equals;2.20801128786324

(10)

Interactive Exploration of Random Variables

The command ExploreRV takes an arbitrary statistical distribution and displays an interactive interface to explore its various parameters.

ExploreRV(NormalRandomVariable(mu, sigma));

Random Variables:

Parameters:

&mu;_R4 &sigma;_R4

Statistical Properties:

Mean

Support

Median

Variance

Mode

Moment Generating Function

Probability Distribution Function

 

Cumulative Distribution Function

 

Example 1

Distribution1 := BinomialRandomVariable(7,1/2):

Mean(Distribution1);

72

(11)

StandardDeviation(Distribution1);

127

(12)

To return a numeric value, add the numeric option.

StandardDeviation(Distribution1, numeric);

1.322875656

(13)

Setting the output option to plot returns a plot demonstration.

ProbabilityFunction(Distribution1,x,output=plot);

CDF(Distribution1, 3, output = plot);

To get the formula for computing a specific property of a distribution, specify the optional parameter inert or inert=true.

Probability(Distribution1 <= 4, inert);

_t3&equals;04&lcub;0_t3<0binomial7&comma;_t312_t3127_t3otherwise

(14)

Example 2

To randomly generate a data sample from a known distribution with the specified sample size, use the Sample command.

Sample1 := Sample(ExponentialRandomVariable(5), 1000);

Sample1:= 1 .. 1000 VectorrowData Type: float8Storage: rectangularOrder: Fortran_order

(15)

InterquartileRange(Sample1);

5.21348341554859

(16)

Median(Sample1);

3.06138615867682

(17)

Compare the data sample generated and the original distribution.

Sample(ExponentialRandomVariable(5), 1000, output = plot);

Test if this sample follows the exponential distribution with parameter 5.

ChiSquareSuitableModelTest(Sample1, ExponentialRandomVariable(5));

Chi-Square Test for Suitable Probability Model

----------------------------------------------
Null Hypothesis:
Sample was drawn from specified probability distribution
Alt. Hypothesis:
Sample was not drawn from specified probability distribution
Bins:                    32
Degrees of freedom:      31
Distribution:            ChiSquare(31)
Computed statistic:      33.472
Computed pvalue:         0.348188
Critical value:          44.9853428040743
Result: [Accepted]
There is no statistical evidence against the null hypothesis

hypothesis&equals;true&comma;criticalvalue&equals;44.9853428040742&comma;distribution&equals;ChiSquare31&comma;pvalue&equals;0.348188188879230&comma;statistic&equals;33.47200000

(18)

Example 3

Create a Matrix data sample:

Matrix1 := Matrix(5, 3, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3, (2, 1) = 2, (2, 2) = Pi, (2, 3) = 5, (3, 1) = 9, (3, 2) = 7, (3, 3) = 3, (4, 1) = 5, (4, 2) = 5, (4, 3) = 2, (5, 1) = 2, (5, 2) = 8, (5, 3) = 10}):

Computing the mean of the matrix returns the three list or Vector data samples stored in the corresponding columns.

Mean(Matrix1);

195225&plus;15&pi;235

(19)

To have both value and plot returned, specify the option output=both.

Value, Graph := InterquartileRange(Matrix1, output = both):

Value;

37&pi;2

(20)

Graph;

See Also

Student, Student[Statistics], Student[Statistics][HypothesisTest], Student[Statistics][RandomVariable]


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