Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

stats::moment

The K-th moment of a data sample

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

stats::moment(k, X, x1, x2, …)
stats::moment(k, X, [x1, x2, …])
stats::moment(k, X, s, <c>)

Description

stats::moment(k, X, [x1, x2, …, xn]) returns the k-th moment

of the data xi centered around X.

If k is an integer, rational or float, and all data X, x1, x2, … are floating-point numbers, then the moment is returned as a floating-point number. For symbolic data, a symbolic expression is returned.

The column index c is optional if the data are given by a stats::sample object containing only one non-string column.

External statistical data stored in an ASCII file can be imported into a MuPAD® session via import::readdata. In particular, see Example 1 of the corresponding help page.

Environment Interactions

The function is sensitive to the environment variable DIGITS which determines the numerical working precision.

Examples

Example 1

We calculate the third moment of some data centered around 0:

stats::moment(3, 0, 2, 33/7, 21/9, PI)

Alternatively, the data may be passed as a list:

data := [2, 33/7, 21/9, PI]: stats::moment(3, 0, data)

If all data are floating-point numbers, the result is a float:

data := float(data): stats::moment(3, 0, data)

We use stats::moment to compute the variance of the data:

m := stats::mean(data):
stats::moment(2, m, data) = stats::variance(data, Population)

delete data, m:

Example 2

We create a sample of type stats::sample:

s := stats::sample([[22, 4, 1], [9, 8/3, 1], [0.1, 2, 3]])
 22    4  1
  9  8/3  1
0.1    2  3

The fourth moment around a symbolic center X is computed for all columns in the sample:

stats::moment(4, X, s, i) $ i = 1..3

delete s:

Example 3

For symbolic arguments, the moment is returned as a symbolic expression:

stats::moment(k, X, [x1, x2, x3, x4])

Parameters

k

An arithmetical expression

X

The center: an arithmetical expression

x1, x2, …

The statistical data: arithmetical expressions

s

A sample of domain type stats::sample

c

A column index of the sample s: a positive integer. This column provides the data x1, x2, ….

See Also

MuPAD Functions

Was this topic helpful?