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
Mean(A);
53
Correlation(A, A^2);
111370⁢10⁢1370
M := Matrix([[1,2,4,1],[2,4,1,2],[6,5,2,7],[1,2,0,9]]);
Variance(M);
L := [1, 2, 3, 1, 2, 3, 1, 2, 2, 2, 6, 2, 3, 4, 5, 2, 4]:
Mode(L);
2
Percentile(L, 30);
Formulas
B := NormalRandomVariable(1,2):
Probability(B<x, inert);
∫−∞x14⁢2⁢ⅇ−18⁢_t2−12πⅆ_t2
CumulativeDistributionFunction(B, 3, output=plot);
Hypothesis Testing
X := [6, 3, 2, 1, 9, 1, 2, 3, 3, 2]:
StandardDeviation(X);
115⁢1390
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=true,criticalvalue=9.48772903678116,distribution=ChiSquare⁡4,pvalue=0.697562873819393,statistic=2.20801128786324
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):
Mean(Distribution1);
72
StandardDeviation(Distribution1);
12⁢7
To return a numeric value, add the numeric option.
StandardDeviation(Distribution1, numeric);
1.322875656
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=04{0_t3<0binomial⁡7,_t3⁢12_t3⁢127−_t3otherwise
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);
5.21348341554859
Median(Sample1);
3.06138615867682
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));
---------------------------------------------- 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=true,criticalvalue=44.9853428040742,distribution=ChiSquare⁡31,pvalue=0.348188188879230,statistic=33.47200000
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);
To have both value and plot returned, specify the option output=both.
Value, Graph := InterquartileRange(Matrix1, output = both):
Value;
Graph;
See Also
Student, Student[Statistics], Student[Statistics][HypothesisTest], Student[Statistics][RandomVariable]
Download Help Document