Mathematica – The Best Fit for Your Statistics Classroom

Craig Bauling

Wolfram Research, Inc.

Outline

About Mathematica

What is Mathematica?

User community & resources

Workflow

Mathematica in the Statistics Classroom

Descriptive statistics

Work with your data, or ours

More statistical distributions than any other system

Visualize charts to data to distributions

Probability & expectation computation

Fitting, testing, & analysis

Simulate anything

A Case Study

Journal of Statistics Education

About Mathematica

What is Mathematica?

Mathematica is many things...

Join a well-established community

Collaborate with users around the world and share ideas through venues like the MouseOver.

Row[{
Show[,ImageSize->ImageDimensions[]],
Grid[{
{Style["▪","Text",Black],
Style["100% of the world's top 200","Text",Black]},
{SpanFromAbove,
Style["universities have Mathematica","Text",Black]},
{},
(*
{Style["▪","Text"],
Style["90% of the world's top 200","Text"]},
{SpanFromAbove,
Style["universities have Mathematica","Text"]},
{SpanFromAbove,
Style["broadly available for students","Text"]}
*)
{Style["▪","Text",Black],
Style["98% of the top 50 US liberal","Text",Black]},
{SpanFromAbove,
Style["arts colleges have Mathematica","Text",Black]}
(*
,
{Style["▪","Text"],
Style["86% of the top 50 US liberal","Text"]},
{SpanFromAbove,
Style["arts colleges have Mathematica","Text"]},
{SpanFromAbove,
Style["broadly available for students","Text"]}*)
},Alignment->Left]
}]

Enhance your classroom

Prebuilt and supplementary materials allow you to jump-start your use of Mathematica or enrich your students’ learning experience.

A look at workflow

Mathematica is easy to use, thanks to free-form input and point-and-click palettes.

Free-form input

Simply type an equal sign, give a command in plain English, and ⇧+⌤ to get the result.

Free-form input lets you start getting results immediately; compare this with another method that comes straight from an instruction manual...

Point-and-click palettes

The Classroom Assistant palette provides a point-and-click experience for many common operations.

RandomInteger[{min,max},number]

Quartiles[list]

Fit[data,{1,x,(x^2)},x]

Three simple rules

Once you’re comfortable, you can type commands in directly using these three rules:

Command names are capitalized

[ ] surround function arguments

{ } are used for lists and ranges

Mean[{10,20,30,40,50}]

CountryData["Australia","Population"]

DateListPlot[CountryData["Afghanistan",{{"Population"},{1970,2005}}]]

The only limit is your imagination...

Manipulate[
Framed@Column[{
Style[CountryData[country,"Name"],FontFamily->"Arial",Bold],
Row[{
Pane[CountryData[country,"Shape"],{100,100},ImageSizeAction->"ShrinkToFit"],
Spacer[30],
Pane[CountryData[country,"Flag"],{100,100},ImageSizeAction->"ShrinkToFit"]
}],
Quiet[DateListPlot[CountryData[country,{{"Population"},{1970,2005}}],BaseStyle->Directive[FontFamily->"Arial"],Joined->True,Filling->Bottom,ImageSize->300,Mesh->All,PlotLabel->Style["Population growth",FontFamily->"Arial",14,Bold]]]
}],
{country,CountryData[]}]

Mathematica in the Statistics Classroom

Descriptive statistics

(Labeled[, "                    distribution of salaries at a university"])

Mathematica’s descriptive statistics commands operate on explicit data, symbolic elements, hybrid numeric-symbolic datasets, and symbolic representations of statistical distributions.

Univariate measures

Many measures are available, including location measures, dispersion measures, shape measures, and general measures (MouseOver).

Example: Median of a numeric dataset

Median[{2,3,5,7,11,13,17,19,23,29}]

Example: Mean of a symbolic dataset

Mean[{(Subscript[x, 1]),(Subscript[x, 2]),(Subscript[x, 3]),(Subscript[x, 4]),(Subscript[x, 5])}]

Example: Mode in a hybrid symbolic-numeric dataset

Commonest[{3,1,x,2,3,x,2,x,x,3}]

Example: Standard deviation of a binomial distribution with 100 trials and probability p

StandardDeviation[BinomialDistribution[100,p]]

Multivariate measures

You can also compute multivariate measures.

Example: Covariance for machine-precision real numbers

Covariance[{1.5,3,5,10},{2,1.25,15,8}]

Example: Correlation matrix for a symbolic matrix

Correlation[(({{a, b}, {c, d}}))]

Many tools allow you to calculate descriptive statistics, but Mathematica gives you the flexibility of working with symbolic calculations and arbitrary-precision arithmetic, making it a more powerful tool for this type of work.

Work with your data, or ours

Mathematica allows you to quickly and easily import your data for visualization, manipulation, or analysis.

Import & export

Hundreds of file types are supported for import and export, like XLS, XLSV, CSV, and TXT (MouseOver).

Example: Import a local file

data=Import[FileNameJoin[{NotebookDirectory[],"S0x-Statistics-SupplementalFiles","SampleNoisyData.xls"}],{"Data",1}];
ListPlot[data]

Example: Import a file from the web

Let’s look at university salaries. We start by importing an Excel spreadsheet from the web.

saldata=Import["http://www.archive.org/download/StateUniversitiesOfIllinoisSalaries2008/ISU-salaries-2008.xlsx",{"Data",1}];

After some data manipulation, we’re ready to look at some interesting results.

Expand to see more details about the data manipulation

I happen to know this data set has headers in the first row, so let’s peel those out:

headers=saldata[[1]]

We can stuff the rest of the data back into the same variable.

saldata=Rest[saldata];

This data happens to contain both monthly and hourly salaries. We are only interested in monthly salaries, so let’s refine our data.

saldata=Select[saldata,#[[4]]>100&];

Let’s take a look at a random employee.

saldata[[300]]

This spacing is a result of how the data was entered into the file to begin with, so let’s clean that up. Luckily, Mathematica is excellent for this type of work.

For[i=1,i≤Length[saldata],i++,saldata[[i,{1,2,3}]]=StringReplace[saldata[[i,{1,2,3}]],{"  "..->""}];]

We can check that this worked:

saldata[[300]]

Now we can work on an actual problem. Let’s try to find the mean salary for each department. First, we’ll need a list of all of the departments, which we can find by extracting the third column and applying the Union function.

depts=Union[saldata[[All,3]]];
TableForm[depts]

Since we have a comprehensive list of departments, let’s manipulate our data to create a new data set that has the following form: {department name, salary}.

deptsals=saldata[[All,{3,4}]];

Now we can calculate the mean annual salary for a specific department. (Remember, we need to multiply by 12 because our data was for monthly salaries).

12*Mean[Select[deptsals,#[[1]]=="Mathematics"&][[All,2]]]

It was easy to calculate the mean for a specific department, but what we really want is to calculate the mean for every department automatically, and it would be nice to also store this data in a list with the corresponding department name so we can keep track of which mean salary goes with which department. For our purposes, let’s also round  the salaries to the nearest dollar. Thankfully, Mathematica makes all of this very easy.

finaldeptsals=Table[{i,Ceiling[12*Mean[Select[deptsals,#[[1]]==i&][[All,2]]]]},{i,depts}]

For example, we can do all sorts of analysis, like ranking the departments by their mean salary:

Manipulate[Part[Reverse[SortBy[finaldeptsals,Last]],1;;n],{{n,10,"show departments"},1,100,1},SaveDefinitions->True]

Or we might want to visualize a histogram of the mean salaries:

Histogram[finaldeptsals[[All,2]],ChartStyle->"Rainbow"]

Curated data

Mathematica gives you access to 10 trillion (and ever increasing!) pieces of curated data. You can access data with free-form input or by using special commands, making it very easy to get data that’s immediately ready for computation without time spent searching or post-processing.

Example: Looking up ease of doing business with free-form input

Example: Looking up performance for a particular stock

It’s easy to query data and assign it to a variable to use later.

performance=FinancialData["AAPL",{2011,9,1}];

For example, now we can plot the stock’s performance:

DateListPlot[performance,Joined->True,Filling->Bottom]

It’s easy to evaluate Moving Averages, Weighted Moving Averages:

Show[{ListPlot[performance[[All,2]]],ListLinePlot[MovingAverage[Part[performance[[All,2]]],5]]}]

As an end result we can create an easy Interactive Demonstration that allows for discussion on the effect of the number of samples used in the Moving Average:

Manipulate[Show[{ListPlot[performance[[All,2]]],ListLinePlot[MovingAverage[Part[performance[[All,2]]],n]]}],{{n,1,"Points to Average"},1,20,1}]

Mathematica’s robust support for import and export, data manipulation capabilities, and notebook interface make it an ideal tool for working with statistical data.

More statistical distributions than any other system

(Labeled[, "distribution coverage in Mathematica"])

Mathematica is unique in its breadth of built-in distributions, including specialized distributions for actuarial science, communication, life sciences, and engineering. And thanks to Mathematica’s software design, using distributions with other functions just works, regardless if the distribution is continuous or discrete; univariate or multivariate; or named, derived, or defined by data.

Named distributions

Many properties are available, including PDF, CDF, and moments.

Example: PDF of a certain normal distribution

PDF[NormalDistribution[0,1],x]

Example: Numeric Computation for hundreds of common distributions

Variance[ChiSquareDistribution[4]]

Example: Plot of a CDF of a multivariate Poisson distribution

DiscretePlot3D[CDF[MultivariatePoissonDistribution[5,{2,3}],{x,y}],{x,0,15},{y,0,15},ExtentSize->Right]

Example: Moment generating function for a binomial distribution

MomentGeneratingFunction[BinomialDistribution[n,p],t]

Nonparametric distributions

Mathematica allows you to create distributions based on data, such as empirical distributions.

Example: Creating nonparametric distributions from empirical data

We can create an empirical distribution for time to failure for aircraft windows. We do this by first loading time to failure data from Mathematica’s built in data sets.

glass=ExampleData[{"Statistics","AirplaneGlass"}]
emp=EmpiricalDistribution[glass];

Our new distribution is discrete since it is based on empirical values, but we can create a continuous distribution as well.

kern=SmoothKernelDistribution[glass];

Let’s look at the PDFs for our distributions.

Show[DiscretePlot[PDF[emp,x],{x,glass},FillingStyle->Opacity[.6],PlotRange->{{10,60},All},PlotLabel->"PDF"],Plot[PDF[kern,x],{x,10,60},PlotStyle->{{ColorData[1,2],Thick}}]]

With more built-in distributions than any other system, and the ability to create your own through mixtures, Mathematica provides an unparalleled platform for working with distributions.

Deriving new distributions

You can construct new distributions based on relationships with other distributions, or based on defining properties of a distribution. Constructors include ProbabilityDistribution and MixtureDistribution (MouseOver).

Example: Creating a new distribution by mixing two normal distributions

The heights of females in the United States follow normal distribution with mean 64 inches and standard deviation of 2 inches, while the heights of males in the United States follow normal distribution with mean 70 inches and standard deviation of 2 inches. If the population ratio of females to males is 1.1:1, then the heights of the whole population have the following bimodal distribution:

height𝒟=MixtureDistribution[{0.47619,1-0.47619},{NormalDistribution[70,2],NormalDistribution[64,2]}];

Now that the distribution is created, we can use it like any other. For example, we can plot the PDF.

Plot[PDF[height𝒟,x],{x,50,80},Filling->Axis]

Example: Creating a new continuous distribution defined by a PDF

probdist=ProbabilityDistribution[((Sqrt[11])/((2 ArcTan[((4 (Sqrt[11]))/17)]) (3+x+(x^2)))),{x,1,9}];

Now that the distribution is created, we can use it like any other. For example, we can ask for the CDF of the distribution.

CDF[probdist,x]

Let’s visualize the PDF and CDF together.

Plot[{PDF[probdist,x],CDF[probdist,x]},{x,0,11},Filling->Bottom]

Visualize charts to data to distributions

"charting""data & distributions"

Mathematica has many specialized functions for statistical visualization, from charting to data plotting. You can also customize and annotate graphics with interactive palettes or through the use of options.

Charting

Even with many charting functions to choose from, they are all structured in a similar way, so often you only need to change the command name to get a different type of result.

chartdata=RandomInteger[{0,10},20];
GraphicsRow[{BarChart[chartdata],BarChart3D[chartdata],PieChart[chartdata],PieChart3D[chartdata]},ImageSize->800]

Data

Quickly visualize datasets in 2D or 3D in a variety of ways.

data2d=RandomReal[{0,1},{50}];
ListPlot[data2d]

Simply change ListPlot to ListLinePlot to get a different visualization.

ListLinePlot[data2d]

Distributions

Plot probability density functions (PDFs), cumulative density functions (CDFs), survival functions (SFs), and hazard functions (HFs).

Example: Plotting the survival function for a normal distribution

Plot[SurvivalFunction[NormalDistribution[0,1],x],{x,-3,3}]

Customization & annotation

Graphics can be customized programmatically with options.

Example: Applying filling to a plot

Plot[SurvivalFunction[NormalDistribution[0,1],x],{x,-3,3},Filling->Axis]

You can also use the Drawing Tools for customization and annotation.

Mathematica doesn’t just allow you to create statistical visualizations – it lets you do so by seamlessly referencing other parts of the system (like a new distribution you just created). This is in contrast to systems that have limited visualization capabilities, forcing you to use multiple programs to get the results you need.

And even though Mathematica is optimized to give you great-looking results, they are fully customizable to your specifications and can be exported in a variety of formats.

Probability & expectation computation

With Mathematica, you can compute probabilities for simple or logical combinations of inequalities and equations.

Example: Computing an exact probability

Let’s define a function to simulate tossing a coin where the outcome is heads.

heads[n_]:=BinomialDistribution[n,1/2]

Now let’s find the probability that if we toss the coin 100 times, we receive between 60 and 80 heads.

Probability[60≤x≤80,x\[Distributed]heads[100]]

We can extract a numerical approximation to any degree of precision.

N[%,75]

Example: Computing a conditional probability

Find the probability that x+y<(7/10) given that y>(1/3), and given that x and y are sampled from a certain Dirichlet distribution. This time, we will compute the numerical probability directly without obtaining an exact result first.

NProbability[x+y<7/10\[Conditioned]y>1/3,{x,y}\[Distributed]DirichletDistribution[{1,3,4}]]

Example: Computing a symbolic probability

What is the probability that (k^2)>10 or k<2 given that k is sampled from a Poisson distribution with mean λ?

Probability[k^2>10||k<2,k\[Distributed]PoissonDistribution[λ]]

Unlike other systems, Mathematica allows you to do symbolic probability calculations with arbitrary-precision arithmetic, so you can work on your problems of interest without being limited by the technology you’re using.

Fitting, testing, & analysis

Mathematica’s provides model fitting functions for an easy way to analyze data, as well as built-in testing capabilities.

Model fitting

Example: Linear model fitting

Let’s import the same spreadsheet of data we used earlier.

data=Import[FileNameJoin[{NotebookDirectory[],"S0x-Statistics-SupplementalFiles","SampleNoisyData.xls"}],{"Data",1}];
ListPlot[data,ImageSize->400]

Now, let’s try to fit a model to the data (in this case, a third-degree polynomial).

model=LinearModelFit[data,{1,x,(x^2),(x^3)},x]

We can visualize the fit:

Show[ListPlot[data],Plot[model[x],{x,-5,15},PlotStyle->Red],ImageSize->400]

And we can extract other properties from the model:

model["Properties"]

For example, here is the ANOVA table:

model["ANOVATable"]

Example: Nonlinear model fitting

Let’s simulate some data of the form {x, (e^(-((2.3` x)/((x^2)+0.4` x+11))))} with an additional random component to add some noise.

data=BlockRandom[SeedRandom[12345];Table[{x,Exp[-2.3 x/(11 +.4 x+x^2)]+RandomReal[{-.5,.5}]},{x,RandomReal[{1,15},20]}]];

Now, we’ll fit a nonlinear model to the data.

nlm=NonlinearModelFit[data,Exp[a x/(b+c x)],{a,b,c},x]

We can use the properties of the model to extract other information, like 90%, 95%, 99%, and 99.9% confidence bands.

{bands90[x_],bands95[x_],bands99[x_],bands999[x_]}=Table[nlm["MeanPredictionBands",ConfidenceLevel->cl],{cl,{.9,.95,.99,.999}}];

And we can put this all together to visualize our data, the fit, and the confidence bands.

Show[ListPlot[data],Plot[{nlm[x],bands90[x],bands95[x],bands99[x],bands999[x]},{x,1,15},Filling->{2->{1},3->{2},4->{3},5->{4}}],ImageSize->400]

Hypothesis testing

Mathematica’s hypothesis testing covers tests of location, variance, or scale, and distributional goodness of fit.

Example: Comparing heart weights between male and female house cats

We start by importing some data:

{sex,heart,weight}=Transpose[ExampleData[{"Statistics","FisherCats"}]];

The heart weight of male cats is significantly greater than that of female cats:

LocationTest[{Pick[heart,sex,"M"],Pick[heart,sex,"F"]},0,"TestDataTable",AlternativeHypothesis->"Greater"]

Perhaps this is because male cats are just larger in general. Let’s visualize the heart weight-body weight ratio for the sexes.

SmoothHistogram[{maleHBR=Pick[heart/weight,sex,"M"],femaleHBR=Pick[heart/weight,sex,"F"]},PlotStyle->Thick]

The ratio of heart weight to body weight is not significantly different between the sexes:

LocationTest[{maleHBR,femaleHBR},0,"TestDataTable"]

Using Mathematica’s integrated fitting, testing, and analysis capabilities helps you complete you statistical analysis workflow in a single environment.

Simulate anything

Pseudorandom number generation, random variate generation, and the ability to create interactive models allow you to simulate whatever phenomena interests you.

Random numbers & variates

Mathematica can generate pseudorandom integers, reals, and complex numbers, random variates from distributions, and other random items (MouseOver).

Example: Simulate a throw of a fair six-sided die

RandomVariate[DiscreteUniformDistribution[{1,6}],1]

Example: Simulate throwing a pair of fair six-sided die

RandomVariate[DiscreteUniformDistribution[{1,6}],2]

Example: Simulate throwing a pair of fair six-sided die 10 times

RandomVariate[DiscreteUniformDistribution[{1,6}],{10,2}]

Example: Or engage your students with an interactive demonstration to simulate throwing a pair of fair six-sided die many times

Example: Generate a 5×5 array of random reals in the range -1 to 1

RandomReal[{-1,1},{5,5}]

Example: Simulate a continuous probability distribution

First, we generate random variates from a specific normal distribution.

data=RandomVariate[NormalDistribution[1,3],10^4];

Now we plot a histogram of our data against the PDF of the distribution.

Show[
Histogram[data,20,"ProbabilityDensity"],
Plot[PDF[NormalDistribution[1,3],x],{x,-9,9},PlotStyle->Thick]]

Manipulate

Mathematica provides an incredibly easy way to generate interactive models with the use of the Manipulate function. Simply wrap Manipulate around an expression, introduce some parameters, and give a range for the parameters – Mathematica does the rest.

Example: Examining the normal distribution

We start with a plot of the PDF of a specific normal distribution.

Plot[PDF[NormalDistribution[0,1],x], {x,-8,8}, PlotRange->{0,.8},ImageSize->400,Filling->Bottom]

Now we make it interactive so that we can explore the location and shape of a variety of normal distributions.

Manipulate[Plot[{PDF[NormalDistribution[0,1],x],PDF[NormalDistribution[mu,sigma],x]}, {x,-8,8}, PlotRange->{0,.8},ImageSize->{500,400},Filling->0], {{mu, 0, "mean"}, -3,3}, {{sigma, 1, "standard deviation"}, .5,2}]

Example: Examining how sample size affects descriptive statistics

We start with a simple function that takes a dataset and returns a table of its length, mean, standard deviation, and variance.

myFunction[dataset_]:=
Grid[{
{"Length: ",Length[dataset]},
{"Mean: ",Mean[dataset]},
{"Standard Deviation: ",StandardDeviation[dataset]},
{"Variance: ",Variance[dataset]}},Alignment->Left,Frame->True,Dividers->All]

myFunction[RandomVariate[NormalDistribution[1,2],10]]

Now let’s make it interactive so that we can vary the sample size to see how that affects the descriptive statistics.

Manipulate[myFunction[RandomVariate[NormalDistribution[1,2],n]],{n,10,10000,1},SaveDefinitions->True]

Mathematica’s Manipulate command is uniquely suited to instant creation of interactive models, compared to other systems that required a lot more coding. This means you can spend less time on stuff you don’t care about (like computer programming) and more time on actually investigating the behavior you’re interested in.

We also have 7,300+ prebuilt models (with downloadable source code) available at the MouseOver, which is the biggest repository of its kind on the web.

A Case Study

Journal of Statistics Education study

The Journal of Statistics Education conducted a study in which students were surveyed to identify key areas where their statistics education could have been improved. Their responses focused on six topics.

Performing mathematical operations

In the study, many students highlighted performing mathematical operations as an area of concern. This isn’t surprising – many students that take statistics are studying fields like sociology, psychology, nursing, and business and may not have strong mathematical backgrounds and thus struggle with mathematical operations, especially if those operations are presented in a formal way. Let’s take the definition of an arithmetic mean:

(OverBar[x])=(((Subscript[x, 1])+(Subscript[x, 2])+(Subscript[x, 3])+...+(Subscript[x, n]))/n)=(((∑_(i=1)^n)(Subscript[x, i]))/n)=(1/n)(∑_(i=1)^n)(Subscript[x, i])

This definition intimidates a lot of students because they are not used to the mathematical notation, but free-form input lets students calculate means (and all types of statistical calculations) in a language that’s comfortable to them.

StandardDeviation[PoissonDistribution[100]]

Only Mathematica gives students such an easy way to perform their mathematical operations.

Designing and validating methods of solution

Students have different learning styles, and this affects how they might approach a problem that requires them to design and validate a method of solution. For example, take the problem of calculating the probability of rolling a 7 with two dice.

Students can approach this many different ways. One student might use free-form input to look up information about the probability directly:

Others might create a table of all possible outcomes, then calculate the probability by hand:

Table[i+j,{i,1,6},{j,1,6}]

Others might use a discrete uniform distribution to calculate the probability:

Probability[dice1+dice2==7,{dice1\[Distributed]DiscreteUniformDistribution[{1,6}],dice2\[Distributed]DiscreteUniformDistribution[{1,6}]}]

These are simply three ways to attack this problem, but Mathematica supports this quite nicely: from offering students different ways of interacting with the system to its thousands of built-in functions, Mathematica gives students the flexibility to work on problems with an approach that makes the most sense to them.

Applying statistics methodology in real life

Mathematica is the perfect tool for applying statistics methodology to real life situations. You can take a statement like the one above, which was heard on television and correlates high temperatures with an increase in crime, and explore whether that’s actually true.

We start by importing some crime data (available from the City of Chicago website as a CSV file) and visualizing the trend for one year.

crimes=Import[FileNameJoin[{NotebookDirectory[],"S0x-Statistics-SupplementalFiles","Crimes.csv"}],"Data"];
crimedates=Table[crimes[[n,2]],{n,3,Length[crimes]}];
crimetally=Tally[crimedates];
DateListPlot[crimetally,ImageSize->400]//Quiet

Next, we use Mathematica’s built-in data to download temperature information for the same time period.

chicagoweather=Reverse[WeatherData["Chicago","MaxTemperature",{{2010,07,27},{2011,07,20},"Day"}]];
DateListPlot[chicagoweather,ImageSize->400]

The two datasets do look similar, so let’s plot a graph of temperature vs. number of crimes and try to find a fit to that new dataset.

chicagodata=Table[{chicagoweather[[n,1]],chicagoweather[[n,2]],crimetally[[n,2]]},{n,1,Length[chicagoweather]}];
data=Table[{chicagodata[[n,2]],chicagodata[[n,3]]},{n,1,Length[chicagodata]}];
dataplot=ListPlot[data,AxesLabel->{"Temperature (°C)","# of Crimes"}];
crimeweathermodel=LinearModelFit[data,x,x];
Show[dataplot,Plot[Normal[crimeweathermodel],{x,Min[chicagodata[[All,2]]],Max[chicagodata[[All,2]]]},PlotStyle->{Red,Thick}],Frame->None,ImageSize->400]

Finally, let’s make this into an interactive model.

Manipulate[Column[{Text[Style[Row[{"We predict Chicago will have ",IntegerPart[841.6198024021244` +8.52568706844138`  deg]," crimes today."}],Gray,FontFamily->"Arial",18]],Show[dataplot,Graphics[{Thick,Dashed,Red,Arrow[{{deg,0},{deg,841.6198024021244` +8.52568706844138`  deg}}]}],Plot[Normal[crimeweathermodel],{x,Min[chicagodata[[All,2]]],Max[chicagodata[[All,2]]]},PlotLabel->ToString[841.6198024021244` +8.52568706844138`  deg],LabelStyle->Directive[Bold,Orange]],Graphics[{Thick,Dashed,Red,Arrow[{{deg,841.6198024021244` +8.52568706844138` deg},{0,841.6198024021244` +8.52568706844138` deg}}]}],ImageSize->500]},Center],{{deg,5,"Temperature (°C)"},-10,30,Appearance->"Labeled"},SaveDefinitions->True]

Mathematica provides the power and flexibility to take data or statements from real life and apply statistical methodology and analysis. You could accomplish this with multiple other tools but would be hard-pressed to find any that provide a complete workflow, from start to finish, for this type of exploration.

Presenting data in the classroom

As a teacher, you likely use multiple tools to help you present data in your classroom. You might use one tool for creating slideshows for lecture presentations, and another tool for creating handouts for your students, and another tool for calculation, and another for data analysis, and so on. And this is necessary because while your slideshow tool might be good for showing slides, it doesn’t let you do calculations; and while your calculation tool does a fine job of giving you numerical answers, it doesn’t let you present a well-formatted document as a handout...

Mathematica is unique in this respect since it meets all of these needs in a single tool, as I hope you’ve seen in this presentation.

Use of technology

Today’s students are generally comfortable with technology and want to see it employed in the classroom, but they don’t want to feel intimidated by the technology that’s chosen.

With Mathematica, this isn’t an issue. Students can work on problems using everyday language, thanks to free-form input.

Or they can use the Wolfram Statistics Course Assistant App, which has an intuitive interface to guide them through solving their problem of interest.

Or they can use an interactive model from the Wolfram Demonstrations Project, which requires no special knowledge of Mathematica, but can still help them understand the concept at hand.

Manipulate[
results=CoefficientList[Expand[ (Sum[x^i,{i,numSides}])^numDice ],x];
If[tablestart>Max[1,numDice (numSides-1) - 14], tablestart=1];
With[{
table = Table[
{i,
NumberForm[results[[i+1]]//N,{6,0}],
NumberForm[100results[[i+1]]/Total[results]//N,{4,2}],NumberForm[Total[results]/results[[i+1]]//N,{5,1}]},
{i,numDice,numDice× numSides}
],
plot = Transpose[{Range[numDice,numDice numSides],Take[results,-numDice(numSides-1)-1]
}]},
Pane[Grid[{{
Text@Grid[
Prepend[
If[Length[table]≤15,Join[table,Table[{"","","",""},{15-Length@table}]],Take[table,{tablestart,tablestart+15}]],
{"roll","chances","% chance","freq."}
],Alignment->Right,ItemSize-> {{3,6,6,6}}
],
ListLogPlot[If[Length[plot]<18,plot,{Take[plot,{1,tablestart-1}],Take[plot,{tablestart,tablestart+15}],If[tablestart<Max[1,numDice (numSides-1) - 14],Take[plot,{tablestart+16,numDice (numSides-1) }],Sequence@@{}]}],{ImageSize->140,PlotRange->{{0,All},{0,All}},Filling->Axis,AspectRatio-> 2,AxesLabel->{"roll","chances"},PlotLabel->Row[{Text[numSides], " sides, ", Text[numDice]," dice"}] }]
},
{Row[{Text@"total chances: ",Text[Total[results]]}],SpanFromAbove}},Frame->All], Alignment-> Center]],
{{numDice,4,"number of dice"},1,10,1, Appearance-> "Labeled"},
{{numSides,8,"number of sides"},{2,4,6,8,10,12,20},ControlType->SetterBar},
{{tablestart,1,"table\nstart"},Max[1,numDice (numSides-1) - 14],1,-1,ControlPlacement->Left,ControlType->VerticalSlider}, TrackedSymbols-> Manipulate]

Using Mathematica as your technology of choice in the statistics classroom can provide immediate benefit to your students.

Supplemental exercises

Perhaps surprisingly, students in the study responded that they wanted to be given more exercises. As a teacher, you may feel limited by only using exercises in the textbook you’re teaching from. Luckily, a little knowledge of Mathematica goes a long way towards developing your own random problem generator.

Panel[DynamicModule[{numproblems = 10,vlow = 10,vhigh = 25,anglelow = 30,anglehigh = 60,glow = 9.81,ghigh = 12.5, findmean = 1,z = 1,findmode = 0,findmedian = 1, findstddev = 1}, 
  Column[{
Style["Descriptive Statistics Random Problem Generator", Black,Bold,FontFamily->"Arial",16], 
Style["Generate random homework and quiz problems",FontFamily->"Arial",14,Bold,GrayLevel[0.5]],
Row[{
Style["Minimum number of values to include in data set: ",FontFamily->"Arial",12],
InputField[Dynamic[vlow],FieldSize->3]}],
Row[{
Style["Maximum number of values to include in data set: ",FontFamily->"Arial",12],
InputField[Dynamic[vhigh],FieldSize->3]}],
 Row[{
Style["Number of problems: ",FontFamily->"Arial",12],
InputField[Dynamic[numproblems],FieldSize->3]}],
Row[{
Style["Include mean problems? ",FontFamily->"Arial",12],
Setter[Dynamic[findmean], 0, No],
Setter[Dynamic[findmean], 1, Yes]}],
Row[{
Style["Include mode problems? ",FontFamily->"Arial",12],
Setter[Dynamic[findmode], 0, No],
Setter[Dynamic[findmode], 1, Yes]}],
Row[{
Style["Include median problems? ",FontFamily->"Arial",12],
Setter[Dynamic[findmedian], 0, No],
Setter[Dynamic[findmedian], 1, Yes]}],
Row[{
Style["Include standard deviation problems? ",FontFamily->"Arial",12],
Setter[Dynamic[findstddev], 0, No],
Setter[Dynamic[findstddev], 1, Yes]}],
Null,
Button[Style["Generate problems for worksheet",FontFamily->"Arial",12],
{substrandom[numproblems],b=1; nb=CreateDocument[],
NotebookWrite[nb, Cell["Descriptive Statistics Practice Quiz","Title"]],
Do[NotebookWrite[nb,
{Cell[answer[[z]], "Text",FontFamily->"Arial"],
Cell["Answer:", "Text", CellFrame->True,Background->LightBlue,FontFamily->"Arial"]}],
{z, 1, numproblems}]},
Appearance->Automatic, Evaluator->Automatic,Method->"Preemptive",ImageSize->320],
Button[Style["Generate multiple choice question set for CMS import",FontFamily->"Arial",12],
 CellPrint[bbmcrandom(numproblems)],
Appearance->Automatic,Evaluator->Automatic,Method->"Queued",ImageSize->320]}, 
   Alignment->Left,ItemSize->{Automatic, Automatic}],
Initialization :> 
   {substrandom[numproblems$_] :=
Last[{
temp=Table[RandomReal[{0, 1},RandomInteger[{vlow, vhigh}],WorkingPrecision->2],{j, 1, numproblems$}],
calcparameter=Table[RandomChoice[{findmean,findmode,findmedian,findstddev}->{"mean","mode","median","standard deviation"},1],{l,1,numproblems$}],
 answer = Table[{StringJoin[ToString[k],". Calculate the ",Flatten[calcparameter][[k]]," of the following dataset:\n",ToString[temp[[k]]]]},{k,1,numproblems$}]}],
bbmcrandom[numproblems$_] :=
Last[{{
temp=Table[RandomReal[{0, 1},RandomInteger[{vlow, vhigh}],WorkingPrecision->2],{j, 1, numproblems$}],
calcparameter = Table[RandomChoice[{findmean,findmode,findmedian,findstddev}->{"mean","mode","median","standard deviation"},1],{l,1,numproblems$}],
bbanswers =
Table[{{StringJoin[ToString[k],". Calculate the ",Flatten[calcparameter][[k]]," of the following dataset:\n",ToString[temp[[k]]]]},
{If[calcparameter[[k]]=={"mean"},100,0], Mean[temp[[k]]]},
{If[calcparameter[[k]]=={"median"},100,0],Median[temp[[k]]]},
{If[calcparameter[[k]]=={"mode"},100,0], RandomChoice[Commonest[temp[[k]]],1]},
{If[calcparameter[[k]]=={"standard deviation"},100,0],StandardDeviation[temp[[k]]]}},
{k, 1, numproblems$}]}, 
       exportanswers = Table[{bbanswers[[m,1]], 
          RandomSample[{bbanswers[[m,2]], 
            bbanswers[[m,3]], bbanswers[[m,4]], 
            bbanswers[[m,5]]}, 4]}, 
         {m, 1, numproblems$}], 
       quest[n_, q_, s1_, a1_, s2_, a2_, s3_, 
          a3_, s4_, a4_] := ToString[
          StringJoin[
           "\[NumberSign] Start of question:Question ", 
           ToString[n], 
           "\n:TYPE:MC: \nTITLE:Question ", 
           ToString[n], 
           "\n:QUESTION:H:1:0:A\n", 
           ToString[q], " ; \n:ANSWER1:", 
           ToString[s1], ":H\n", ToString[a1], 
           " \n:ANSWER2:", ToString[s2], 
           ":H\n", ToString[a2], "\n:ANSWER3:", 
           ToString[s3], ":H\n", ToString[a3], 
           " \n:ANSWER4:", ToString[s4], 
           ":H\n", ToString[a4], "\n:CAT:Descri\
ptiveStatisticsProblemGenerator\n:SECTION:MeanM\
odeMedianStdDev\n:ASSESSMENT:Test\n\[NumberSign] End of \
question:Question ", ToString[n]]]; 
        str = OpenWrite["Testfile"]; i = 1; 
        While[i <= numproblems$, 
          WriteString[str, quest[i, 
             exportanswers[[i,1]], 
             exportanswers[[i,2,1,1]], 
             exportanswers[[i,2,1,2]], 
             exportanswers[[i,2,2,1]], 
             exportanswers[[i,2,2,2]], 
             exportanswers[[i,2,3,1]], 
             exportanswers[[i,2,3,2]], 
             exportanswers[[i,2,4,1]], 
             exportanswers[[i,2,4,2]]]]; i++]*
         Close[str]; Print[
         "See testfile.txt for question set."]}]\
}, DynamicModuleValues :> {}]]

You can even develop your own games for students...

Manipulate[
Column[{
Style["Pin the Tail on the Distribution", GrayLevel[0.5], FontFamily->"Arial", 18,Bold],
Style["Below you will be shown a graphic of a distribution",FontFamily->"Arial", 12,Bold],
answerkey[[reset,1]],
Style["Check the radio button that best describes the above distribution.", FontFamily->"Arial",12,Bold],
RadioButtonBar[Dynamic[x],RandomSample[{answerkey[[reset,2]],answerkey[[reset,3]],answerkey[[reset,4]]},3],Appearance->"Vertical",LabelStyle->Directive[FontFamily->"Arial",12]], 
Style["After you select the best description, press Grade My Answer.", FontFamily-> "Arial", 12, Bold],
InputField[Dynamic[grade], BaseStyle -> Directive[FontFamily->"Arial",12]]
}, Center],
Button[Style["Grade My Answer",FontFamily->"Arial",12], checker[answerkey[[reset,2]], x]],
Button[Style["Reset",FontFamily->"Arial",12],{reset=RandomInteger[{1, 7}],x="first",grade="Results"}], 
 Initialization :>{
checker[eq_, answer_]:=
If[eq===answer,grade="Correct!Hit Reset,Smarty.",grade="Sorry. Hit Reset and try again"];
μ=0;σ=1;p1=0;p2=1.75;p3=-1.75;reset=RandomInteger[{1, 7}];x="first";grade="Results";
dist1=Show[{
Plot[PDF[NormalDistribution[μ,σ],x],{x,μ-4*σ,μ+4*σ}],
Plot[PDF[NormalDistribution[μ,σ],x],{x,μ-4*σ,p1},Filling->Axis]}];
dist2=Show[{
Plot[PDF[NormalDistribution[μ,σ],x],{x,μ-4*σ,μ+4*σ}],
Plot[PDF[NormalDistribution[μ,σ],x],{x,μ-4*σ,p2},Filling->Axis]}];
dist3=Show[{
Plot[PDF[NormalDistribution[μ,σ],x],{x,μ-4*σ,μ+4*σ}],
Plot[PDF[NormalDistribution[μ,σ],x],{x,μ-4*σ,p3},Filling->Axis]}];
 dist4=Show[{
Plot[PDF[ExponentialDistribution[1.2],x],{x,0,1.2+5}],
Plot[PDF[ExponentialDistribution[1.2],x],{x,0,6.2},Filling->Bottom]}];
dist5=Plot[PDF[HalfNormalDistribution[1.5],x],{x,0,5},Filling->Axis,PlotRange->All];
dist6=Show[{
Plot[PDF[StudentTDistribution[4],x],{x,-5,5}],
Plot[PDF[StudentTDistribution[4],x],{x,-5,1},Filling->Axis]}];
dist7=Show[{
Plot[PDF[LogNormalDistribution[1,1],x],{x,0,4}],
Plot[PDF[LogNormalDistribution[1,1],x],{x,0,p2},Filling->Axis]}];
answerkey={
{dist1,
Style["Normal Distribution Probablity=50%",FontFamily->"Arial"],
Style["HalfNormal Distribution Probability",FontFamily->"Arial"],
Style["Student T Distribution Probability=75%",FontFamily->"Arial"], 1},
 {dist2,
Style["Normal Distribution Probabilty=90%",FontFamily->"Arial"],
Style[ "HalfNormal Distribution Probability",FontFamily->"Arial"],
Style["Student T Distribution Probability=75%",FontFamily->"Arial"], 2},
{dist3,
Style["Normal Distribution Probabilty=10%",FontFamily->"Arial"],
Style["Normal Distribution Probabilty=90%",FontFamily->"Arial"],
Style["Student T Distribution Probability=75%",FontFamily->"Arial"], 3},
{dist4,
Style[ "Exponential Distribution",FontFamily->"Arial"],
Style["Student T Distribution Probability=75%",FontFamily->"Arial"],
Style["LogNormal Distribution Probabilty=50%",FontFamily->"Arial"],
Style["Exponential Distribution",FontFamily->"Arial"], 4},
{dist5,
Style["HalfNormal Distribution Probability",FontFamily->"Arial"],
Style["LogNormal Distribution Probabilty=50%",FontFamily->"Arial"],
Style["Normal Distribution Probablity=50%",FontFamily->"Arial"], 5},
{dist6,
Style["Student T Distribution Probability=75%",FontFamily->"Arial"],
Style["Normal Distribution Probabilty=90%",FontFamily->"Arial"],
Style["Normal Distribution Probablity=50%",FontFamily->"Arial"], 6},
{dist7,
Style["LogNormal Distribution Probabilty=50%",FontFamily->"Arial"],
Style["HalfNormal Distribution Probability",FontFamily->"Arial"],
Style["Exponential Distribution",FontFamily->"Arial"], 7}}; },
ControlPlacement->Bottom]

As you can see, Mathematica addresses all of these requests quite nicely.

Next steps

Query campus or Wolfram about getting an installer

MouseOver

Find out if your organization has a Wolfram site license.

Training

The Wolfram Education Group offers center-based, online, and on-campus training.

MouseOver

Learn how to use the statistical tools available in Mathematica.

MouseOver

Gain familiarity with all parts of Mathematica in this foundational course.

Other resources

MouseOver

Find your learning path with this collection of tutorials, examples, and screencasts.

MouseOver

A repository of 7,300+ free, interactive models for exploring concepts.

MouseOver

Connect with other Mathematica users and access special benefits for teaching.

MouseOver

Mobile applications for iOS devices including the Wolfram Statistics Course Assistant.

MouseOver

Browse textbooks with a Mathematica component.

Questions?

Send email to MouseOver.