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.
>
|
with(Student[Statistics]):
|
|
|
Quantities
|
|
>
|
A := BinomialRandomVariable(5, 1/3):
|
>
|
Probability({A>=2, A<=4});
|
>
|
M := Matrix([[1,2,4,1],[2,4,1,2],[6,5,2,7],[1,2,0,9]]);
|
>
|
L := [1, 2, 3, 1, 2, 3, 1, 2, 2, 2, 6, 2, 3, 4, 5, 2, 4]:
|
|
|
Formulas
|
|
>
|
B := NormalRandomVariable(1,2):
|
>
|
Probability(B<x, inert);
|
| (6) |
>
|
CumulativeDistributionFunction(B, 3, output=plot);
|
|
|
Hypothesis Testing
|
|
>
|
X := [6, 3, 2, 1, 9, 1, 2, 3, 3, 2]:
|
>
|
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
| |
| (8) |
|
|
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:
|
Statistical Properties:
Mean
|
|
Support
|
|
Median
|
|
Variance
|
|
Mode
|
|
Moment Generating Function
|
|
|
|
|
Probability Distribution Function
|
|
|
|
|
|
|
|
Cumulative Distribution Function
|
|
|
|
|
|
|
|
|
|
|
Example 1
|
|
>
|
Distribution1 := BinomialRandomVariable(7,1/2):
|
>
|
StandardDeviation(Distribution1);
|
To return a numeric value, add the numeric option.
>
|
StandardDeviation(Distribution1, numeric);
|
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);
|
| (12) |
|
|
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);
|
>
|
InterquartileRange(Sample1);
|
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
| |
| (15) |
|
|
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.
To have both value and plot returned, specify the option output=both.
>
|
Value, Graph := InterquartileRange(Matrix1, output = both):
|
|
|