Student Statistics - Maple Help

Home : Support : Online Help : System : Information : Updates : Maple 18 : Student Statistics

 Statistics for Students

The Student package is a collection of sub-packages designed to assist with the teaching and learning of standard undergraduate mathematics. For Maple 18, we added a new subpackage called Statistics to the Student family. Student[Statistics] provides more detailed explanations, instructions, and demonstrations about the material covered in statistics courses than is offered in the standard Statistics package.

With the Student Statistics package, students can work with data, visualize statistical distributions, and apply hypothesis tests. Students can even interactively explore the properties of different probability distributions.

There are many ways to interact with this new package. Typically, students will use Student[Statistics] to:

Create Data Samples

There are three types of data samples valid in this package:

 1) A data sample that follows a specific distribution Data samples can easily be created using random variables with corresponding distributions. For example, to create a Normal random variable, one would call NormalRandomVariable(${\mathrm{\mu }}$,${\mathrm{\sigma }}$). For more information, see the Random Variable overview page.
 2) A data sample stored in a list or a Vector Each element in a list or Vector data sample represents a single recorded observation. There is no difference between a list sample and a Vector sample, either is valid.
 3) A data sample stored in a Matrix A Matrix data sample is treated as a collection of several list or Vector samples. Each column of the Matrix represents an individual sample.

Work with Data Samples

 1) Compute quantities of data samples There are many commands for computing quantities of data samples. This includes many different quantities, such as the Mean Value, the Standard Deviation, the Skewness, and many more. Also in this package, users are not only able to query for a symbolic formula or exact numeric value for a given quantity from a data sample, but it is also possible to return a visualization of the result.
 2) Explore distributions Users can easily explore the important properties of a distribution by using the command, ExploreRV. ExploreRV takes an arbitrary statistical distribution and displays an interactive interface to explore its various parameters. This includes returning key quantities, such as the mean, median and more, as well as returning visualizations of the CDF and PDF.
 3) Apply hypothesis tests To test a given hypothesis, there are several hypothesis tests available, including OneSampleTTest, ChiSquareGoodnessOfFitTest, ShapiroWilkWTest, and more. To better explain how and when to use different hypothesis tests, a new command, TestsGuide, is introduced in this package to direct a student through the process of choosing an appropriate test. You can read more on the Hypothesis Tests Overview page.

For more details, read through the Overview of Student Statistics page.

Examples

 > $\mathrm{with}\left(\mathrm{Student}[\mathrm{Statistics}]\right):$

Example

We first define a discrete distribution:

 > $\mathrm{Distribution1}:=\mathrm{BinomialRandomVariable}\left(7,\frac{1}{2}\right):$

Then we can study some properties of this distribution:

 > $\mathrm{Mean}\left(\mathrm{Distribution1}\right)$

$\frac{{7}}{{2}}$

 > $\mathrm{StandardDeviation}\left(\mathrm{Distribution1}\right)$

$\frac{{1}}{{2}}\sqrt{{7}}$

To return a numeric value, we need to specify the optional parameter numeric or numeric=true.

 > $\mathrm{StandardDeviation}\left(\mathrm{Distribution1},\mathrm{numeric}\right)$

${1.322875656}$

We can set the optional parameter output to output=plot to see a plot demonstration.

 > $\mathrm{ProbabilityFunction}\left(\mathrm{Distribution1},x,\mathrm{output}=\mathrm{plot}\right)$

 > $\mathrm{CDF}\left(\mathrm{Distribution1},3,\mathrm{output}=\mathrm{plot}\right)$

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

 > $\mathrm{Probability}\left(\mathrm{Distribution1}\le 4,\mathrm{inert}\right)$

${\sum }_{{\mathrm{_t}}{=}{0}}^{{4}}\phantom{\rule[-0.0ex]{5.0px}{0.0ex}}\left({{}\begin{array}{cc}{0}& {\mathrm{_t}}{<}{0}\\ {\mathrm{binomial}}{}\left({7}{,}{\mathrm{_t}}\right){\left(\frac{{1}}{{2}}\right)}^{{\mathrm{_t}}}{\left(\frac{{1}}{{2}}\right)}^{{7}{-}{\mathrm{_t}}}& {\mathrm{otherwise}}\end{array}\right)$

Try another distribution, which is continuous.

 > $\mathrm{Distribution2}:=\mathrm{NormalRandomVariable}\left(10,3\right):$
 > $\mathrm{Skewness}\left(\mathrm{Distribution2}\right)$

${0}$

 > $\mathrm{Kurtosis}\left(\mathrm{Distribution2}\right)$

${3}$

Example

Say we have observed and recorded some data. We can then put the data onto a list or Vector:

 > $\mathrm{Sample1}:=\left[1,2,3,1,2,3,1,2,2,2,6,2,3,4,5,2,4\right]:$

Compute the mode and the 30th percentile of this data sample:

 > $\mathrm{Mode}\left(\mathrm{Sample1}\right)$

$\left\{{2}\right\}$

 > $\mathrm{Percentile}\left(\mathrm{Sample1},30\right)$

${2}$

We can randomly generate a data sample from a known distribution with a specified sample size.

 > $\mathrm{Sample2}:=\mathrm{Sample}\left(\mathrm{ExponentialRandomVariable}\left(5\right),1000\right)$

${\mathrm{Sample2}}{:=}\left[\begin{array}{c}{\mathrm{1 .. 1000}}{{\mathrm{Vector}}}_{{\mathrm{row}}}\\ {\mathrm{Data Type:}}{{\mathrm{float}}}_{{8}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$

Compare the data sample generated and the original distribution.

 > $\mathrm{Sample}\left(\mathrm{ExponentialRandomVariable}\left(5\right),1000,\mathrm{output}=\mathrm{plot}\right)$

 > $\mathrm{InterquartileRange}\left(\mathrm{Sample2}\right)$

${5.21969438283049}$

 > $\mathrm{Median}\left(\mathrm{Sample2}\right)$

${3.11068660376637}$

Then, test the sample to see if it follows the exponential distribution with parameter 5.

 > $\mathrm{ChiSquareSuitableModelTest}\left(\mathrm{Sample2},\mathrm{ExponentialRandomVariable}\left(5\right)\right)$

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:      30.784
Computed pvalue:         0.477134
Critical value:          44.9853428040743
Result: [Accepted]
There is no statistical evidence against the null hypothesis

$\left[{\mathrm{hypothesis}}{=}{\mathrm{true}}{,}{\mathrm{criticalvalue}}{=}{44.9853428040742}{,}{\mathrm{distribution}}{=}{\mathrm{ChiSquare}}{}\left({31}\right){,}{\mathrm{pvalue}}{=}{0.477134451984691}{,}{\mathrm{statistic}}{=}{30.78400000}\right]$

To read more on different hypothesis tests, you can use the command TestsGuide.

Example

Create a Matrix data sample:

 > $\mathrm{Matrix1}≔\left[\begin{array}{ccc}1& 2& 3\\ 2& \mathrm{π}& 5\\ 9& 7& 3\\ 5& 5& 2\\ 2& 8& 10\end{array}\right]:$

If we want to compute the mean value of this Matrix data sample, then we are going to compute the mean values of three list or Vector data samples stored in the columns correspondingly.

 > $\mathrm{Mean}\left(\mathrm{Matrix1}\right)$

$\left[\begin{array}{ccc}\frac{{19}}{{5}}& \frac{{22}}{{5}}{+}\frac{{1}}{{5}}{\mathrm{π}}& \frac{{23}}{{5}}\end{array}\right]$

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

 > $\mathrm{Value},\mathrm{Graph}:=\mathrm{InterquartileRange}\left(\mathrm{Matrix1},\mathrm{output}=\mathrm{both}\right):$
 > $\mathrm{Value}$

$\left[\begin{array}{ccc}{3}& {7}{-}{\mathrm{π}}& {2}\end{array}\right]$

 > $\mathrm{Graph}$

Example

In our last example, we can use the command ExploreRV to explore some important properties of distributions.

 > $\mathrm{ExploreRV}\left(\mathrm{NormalRandomVariable}\left(1,2\right)\right)$

Random Variables:

Parameters:

 ${\mathrm{mu___R5}}$ ${\mathrm{sigma___R5}}$

Statistical Properties:

 Mean Support Median Variance Mode Moment Generating Function

 Probability Distribution Function

 Cumulative Distribution Function