Statistics - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Statistics

The updates for Statistics in Maple 2015 include several new commands, as well as added support in the context menu for matrix data sets, and new and improved visualizations.

 

Lowess

Robust regression

Scale

Visualizations

More Updates

Lowess

Lowess (locally weighted scatterplot smoothing) is used for plotting a smoothed curve or surface and has been an available option for both ScatterPlot and ScatterPlot3D for several releases. In Maple 2015, the new Lowess command returns the function whose graph is the lowess smoothed curve or surface. Returning a function rather than a plot also means that the Lowess command is capable of handling data points in any finite dimension. The lowess algorithm has also been improved to produce better plots and to achieve lower computation times in routines like ScatterPlot and ScatterPlot3D.

Following is an example of the use of Lowess together with ScatterPlot3D. First, generate 300 data points and store them in a 300x3 Matrix, M.

withStatistics:

XSampleUniform50,50, 300:

YSampleUniform50,50,300:

ZerrorSampleNormal0,100,300:

ZVector'row'300,isinYi20Xi62+Yi72+Zerrori:

M  X, Y, Z%T;

Now, compute the lowess model, L, and plot L.

LLowessM:

Pplot3dL, 50..50,50..50:

Finally, plot the data points by themselves, and display the two plots together.

QScatterPlot3DM:

plots:-displayP,Q,lightmodel=none,orientation=20,70,0,view=50..50,50..50,4000..1500;

The lowess model can also be used in most other contexts where you can use a procedure. For example, you can numerically integrate the volume between the lowess surface and the plane z=0 (this turns out to be negative - there is more volume below zero than above):

intL, 50..50, 50..50, numeric, ε = 0.1, method = _CubaSuave

918.771690686256

(1.1)

In the following example, the data points are two-dimensional (there is one independent and one dependent variable).

XSampleUniform0,50,500:

ZerrorSampleNormal0,0.0005,500:

ZVector'row'500,i0.9Xi1Xi+50+Zerrori  1+ Xi:

LLowessX,Z,bandwidth=0.3:

PScatterPlotX,Z:

QplotL,0..50:

plots:-displayP,Q;

If these data points represent the response to a certain stimulus, you can expect the highest response where the model assumes the highest value. You can find this point with the Maximize command from the Optimization package.

Optimization:-MaximizeL, 0 .. 50;

The maximum, of about 0.012, is assumed when the stimulus is approximately 20. (The number varies a little bit depending on the random samples chosen previously.)

Robust regression

Robust statistics are statistical procedures that give reliable results in the presence of noise. The procedures embodied by the Maple commands Median and HodgesLehmann give robust measures for the location of a data set; those embodied by MedianDeviation, RousseeuwCrouxSn, and RousseeuwCrouxQn give robust measures for the dispersion of a data set. In Maple 2015, there is a new command that performs robust linear regression: RepeatedMedianEstimator.

The setting where this is useful is if one has data points in the plane that include outliers, and one wants to perform linear regression: find an affine-linear expression in the independent variable that is a reasonable description for the dependent variable.

X  SampleUniform0, 50, 500:

Yerror  SampleUniform0, 1, 500:

Y  Vector500, i 1.3Xi +2.7  20Xi502 Yerrori6

points  dataplotX, Y, style=point, symbolsize=4, color=green: points

You see that most points are close to the upper boundary given by the curve, but there are some points substantially lower than that. The standard, least-squares regression gives those lower points a substantial weight (their distance from the regression line is squared). The repeated median estimator, however, treats the outliers as "abnormal" values that get less weight; it lies closer to the majority of points.

leastsquares  Fitax+b, X, Y, x;

0.0965727031076460x+5.58041733925551

(2.1)

repeatedmedian RepeatedMedianEstimatorX, Y, x;

5.53282063219485+0.127503338071007x

(2.2)

plots:-displaypoints, plotleastsquares, repeatedmedian, x=0..50, legend=least squares, repeated median;

Scale

The Scale command is used to center and scale a sample list or matrix. By default, when a sample is centered, the mean of the list is subtracted from each of the observations. When a sample is scaled, all of the observations are divided by the standard deviation of the sample. This has useful applications in statistics, such as to compute standard scores.

 

For example, say that you have a list of percent grades in decimal form which are scored out of a possible maximum value of 1.

Grades .34, .55, .61, .75, .80, .91

0.34,0.55,0.61,0.75,0.80,0.91

(3.1)

withStatistics:

 

A consequence of scaling and centering a sample of data is that the resulting sample has mean 0 and standard deviation 1 (corresponding to a standard normal distribution). Scaling and centering this list, you see that a score of 0.80 is 0.68 standard deviations above the mean for example:

ScaleGrades

 

If you assume that the population of all grades is normally distributed, and that you have a representative sample of them here, then these data suggest that the score corresponding to 0.80 is in the top 25% of the grades, as you can see by using a standard normal distribution table:

Student:-Statistics:-ProbabilityTableNormal, 0.687730305405377

0.754188683982649

(3.2)

 

The following graph illustrates how various options for the Scale command scale and center samples of data:

dataplot Matrix VectorGrades, ScaleGrades, center = false, ScaleGrades, ScaleGrades, scale=false,                                         legend = Data, Scaled Data, Scaled and Centered Data, Centered Data, color=Red, DarkBlue, RoyalBlue,Orange,                                         axes=framed, axis1=color=white

The red line shows the original data and the orange line shows the data minus the center value. The dark blue line shows the data divided by the scale value (the standard deviation of the sample) and the light blue line shows the data minus the center then divided by the scale value (the result of the command used above to compute the standard scores).

Visualizations

There are several notable updates to visualizations in Statistics, including a change to the default axes style for all statistics visualizations to boxed axes. The new dataplot command merges many statistics plots into one convenient place, making it easier than ever to create plots using sample of data. An example of the dataplot command can be seen in the preceding section.

 

TreeMap is a new visualization that creates a unique view on the structure of data samples. A tree map is a method of data visualization using nested rectangles, in which the area of a rectangle corresponds to the magnitude of the corresponding datum.

withStatistics:

TreeMap1=10,2=5,3=15,4=20,5=25

 

The BubblePlot command has also been updated to handle TimeSeries objects. When given a time series, BubblePlot will create an animation that uses the corresponding time series to define the position and size of the bubbles over time. The following plot, taken from the BubblePlot help page, shows the 'Services Share of GDP' vs 'Industry Share of GDP' for several countries over a one year time period as an animation. The bubble size corresponds to the GDP (PPP) value. To view the animation, right-click and choose Animation - Play.

More Updates

Code Generation for R

Maple 2015 introduces the CodeGeneration[R] command, making it easy to translate Maple code to R. In addition to being able to translate fundamental programming structures, CodeGeneration[R] can also translate many common unevaluated commands from statistics.

withCodeGeneration:

R'Statistics:-MeanMatrix2,4,8,21'

cg <- mean(matrix(c(2,4,8,21),nrow=1,ncol=4))

R&apos;Statistics:-FivePointSummary1&comma;3&comma;5&comma;7&comma;9&apos;&colon;

cg0 <- fivenum(c(1,3,5,7,9))

 

For more details, see the CodeGeneration updates page.

Additional Improvements

Several Statistics commands including DataSummary, FivePointSummary, and FrequencyTable have been updated. DataSummary and FivePointSummary have been updated to return a column vector rather than a list, making the results of each command much easier to read:

withStatistics&colon;

DataSummarySampleNormal10&comma;5&comma;100

FivePointSummarySampleRayleigh3&comma;100

The FrequencyTable command has a new option, headers, which controls the display of a header row of information:

FrequencyTableArrayseqnextprimei&comma;i&equals;1..100&comma;headers&comma; bins&equals;3

Statistics Education

Maple 2015 includes numerous updates geared toward the classroom. This includes a new palette for quick creation of random variables, new commands and tutors for working with common probability distribution tables and tables of critical values, and many new MathApps:

 

Chi-Square Distribution

Confidence Intervals

Normal Approximation of Binomial Distribution

Rolling Two Dice

Z-Tests

And many more...