Statistics - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Statistics and Data Analysis : Statistics Package : Data Manipulation : Statistics/Scale

Statistics

  

Scale

  

center and/or scale a set of data

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

Scale( V )

Scale( V, options )

Parameters

V

-

list, matrix, vector, DataFrame, DataSeries; numeric list of elements

options

-

(optional) equation(s) of the form option=value

Options

• 

center  : truefalse, numeric, procedure; controls if the returned list of values is centered or not. The default is set to true, which uses the Statistics[Mean] command to compute the center. If this is set to false, the list is not centered and the list of values will have the same central mean value as before. If a numeric value is entered, the list is centered using that value as its center. If a procedure is entered, the list is centered using the value returned from the procedure.  If a procedure is entered as the first value of a list, subsequent arguments in the list are passed to the procedure.

• 

scale   : truefalse, numeric, procedure; controls if the returned list of values is scaled or not. The default is set to true, which uses the Statistics[StandardDeviation] command to compute the standard deviation. If this is set to false, the list is not scaled and has the same standard deviation as before. If a numeric value is entered, the list is scaled using that value as its standard deviation. If a procedure is entered, the list is scaled using the value returned from the procedure.  If a procedure is entered as the first value of a list, subsequent arguments in the list are passed to the procedure.

• 

ignore  : truefalse; controls how missing data is handled. Missing items are represented by undefined or Float(undefined). If ignore=false and V contains missing data, the Scale command will return undefined. If ignore = true all missing items in V will be ignored. The default value is false. The ignore option is not passed to any procedures entered for either of the center or scale options.

Description

The Scale command is used to center and scale list of elements. If V is a matrix, the Scale command will scale each column of the matrix.

The Scale command can also be used with arbitrary numeric values for the center and scaling factor. In addition, either center or scale can be turned off in order to just return a new scaled or centered set of values respectively.

Examples

withStatistics:

An application for the Scale command is to compute standard scores (z-scores) for a list of values. Standardized scores are useful measures to determine how far a given element is from the sample mean. Standardized scores are computed by first subtracting the mean of the set of data from each element and then dividing the result by the standard deviation of the data set, resulting in a new set of values with mean 0 and standard deviation 1. Given a list of values corresponding to grades on a final examination with a highest possible grade of 100, we can determine how each of the grades rank in terms of the sample mean, and what percentage of scores are higher or lower than a particular grade.

Grades34,55,61,75,80,91

Grades34,55,61,75,80,91

(1)

Say that we wanted to compare a grade of 75 with the other grades. Computing the standard scores using the Scale command, we see that:

ScaleGrades

1.57195498378371860.54035952567565330.24561796621620590.44211233918917080.68773030540537671.2280898310810304

(2)

A grade of 75 corresponds to a standardized score of 0.44, which means that the grade is approximately 1/2 standard deviation above the sample mean.

The percentage of grades that are lower than this standardized score can be found from a standard normal distribution probability table.

Student:-Statistics:-ProbabilityTable'Normal',0.442112339189170811

0.670796042104607

(3)

From the above, 67% of the grades are lower than a grade of 75, or conversely, a grade of 75 is in the top 33% percentile.

Standard scores can also be used to compare two sets of data from different distributions. Say that we wanted to again investigate how a score of 75 ranks for another set of data taken from another examination with a with a highest possible grade of 120:

Grades260,75,90,100,111,115

Grades260,75,90,100,111,115

(4)

The two lists of grades can be put into a grade matrix:

GradeMatrixMatrixGrades,Grades2%T

346055756190751008011191115

(5)

Applying scale to a matrix results in two new columns of data both with mean 0 and standard deviation 1:

ScaleGradeMatrix

1.57195498378371861.49373820418103030.54035952567565330.78988250587583280.24561796621620590.086026807570635630.44211233918917080.38321032463282910.68773030540537670.89937117005664111.22808983108103041.0870660229380267

(6)

In this case, the grade of 75 has a standard score of -0.79, which corresponds to a probability value of:

Student:-Statistics:-ProbabilityTable'Normal',0.789882505875832

0.214798194477153

(7)

In the first set of grades, a score of 75 is in the top 33% of the grades. In the second, a score of 75 is in the bottom 21%.

The Scale command can also be used to just center data:

ScaleGrades,scale=false

32.011.05.09.014.025.0

(8)

Or just scale the data by a numeric factor:

ScaleGrades,scale=2

16.05.52.54.57.012.5

(9)

The following plot illustrates the differences between applying various options to the Scale command. In order to show a greater contrast between transformed data, we will use the grades as decimal percentages:

PercentGradesGrades100.0

PercentGrades0.3400000000,0.5500000000,0.6100000000,0.7500000000,0.8000000000,0.9100000000

(10)

dataplotMatrixVectorPercentGrades,ScalePercentGrades,center=false,ScalePercentGrades,ScalePercentGrades,scale=false,'axes'=boxed,'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) and the light blue line shows the data minus the center then divided by the scale value.

It is possible to use another procedure or command from Statistics to determine the center or scale.

ScaleGrades2,center=Median,scale=Variance

0.077064220183486220.04403669724770640.0110091743119266060.0110091743119266060.0352293577981651340.0440366972477064

(11)

It is also possible to send arguments to the procedures used for the center or scale options by entering the procedure in a list:

W10,5,10,5,10,20:

ScaleGrades2,center=Mean,weights=W

1.7088052231076181.00494952480242050.30109382649722340.168143305706241360.68430415113005340.8719990040114389

(12)

If the collection of data has any undefined values, these can optionally be ignored using the ignore option:

Grades334,55,61,Floatundefined,75,80,91

Grades334,55,61,Floatundefined,75,80,91

(13)

ScaleGrades3,ignore=true

1.57195498378371860.54035952567565330.2456179662162059HFloatundefined0.44211233918917080.68773030540537671.2280898310810304

(14)

If the center or scale options are called with a procedure, the ignore option is not passed to the procedure. To pass ignore to another procedure, it can be given in the list of options for the procedure:

ScaleGrades3,center=Mean,ignore=true,scale=Variance,ignore=true

0.07722007722007720.0265444015444015470.01206563706563707HFloatundefined0.021718146718146730.03378378378378380.060328185328185346

(15)

Compatibility

• 

The Statistics[Scale] command was introduced in Maple 2015.

• 

For more information on Maple 2015 changes, see Updates in Maple 2015.

See Also

Statistics

Statistics[Mean]

Statistics[StandardDeviation]