Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

std

Class: timeseries

Standard deviation of timeseries data

Syntax

ts_std = std(ts)
ts_std = std(ts,Name,Value)

Description

ts_std = std(ts) returns the standard deviation of the timeseries data.

ts_std = std(ts,Name,Value) specifies additional options specified with one or more Name,Value pair arguments.

Input Arguments

ts

The timeseries object for which you want the standard deviation of the data.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'MissingData'

A string specifying one of two possible values, remove or interpolate, indicating how to treat missing data during the calculation.

Default: remove

'Quality'

A vector of integers, indicating which quality codes represent missing samples (for vector data) or missing observations (for data arrays with two or more dimensions).

'Weighting'

A string specifying one of two possible values, none or time.
When you specify time, larger time values correspond to larger weights.

Output Arguments

ts_std

The standard deviation of ts.Data values as follows:

  • When ts.Data is a vector, ts_std is the standard deviation of ts.Data values.

  • When ts.Data is a matrix, and IsTimeFirst is true, and the first dimension of ts is aligned with time, then ts_std is the standard deviation of each column of ts.Data.

When ts.Data is an N-dimensional array, std always operates along the first nonsingleton dimension of ts.Data.

Examples

The following example finds the standard deviation for a timeseries object. MATLAB® calculates the standard deviation for each data column in the timeseries object.

% Load a 24-by-3 data array:

load count.dat

% Create a timeseries object with 24 time values:

count_ts = timeseries(count,1:24,'Name','CountPerSecond');

% Calculate the standard deviation of each data column for this 
% timeseries object:

std(count_ts)

MATLAB returns:

25.3703   41.4057   68.0281

Algorithms

MATLAB determines weighting by:

  1. Attaching a weighting to each time value, depending on its order, as follows:

    • First time point — The duration of the first time interval (t(2) - t(1)).

    • Time point that is neither the first nor last time point — The duration between the midpoint of the previous time interval to the midpoint of the subsequent time interval ((t(k + 1) - t(k))/2 + (t(k) - t(k - 1))/2).

    • Last time point — The duration of the last time interval ((t(end) - t(end - 1)).

  2. Normalizing the weighting for each time by dividing each weighting by the mean of all weightings.

      Note:   If the timeseries object is uniformly sampled, then the normalized weighting for each time is 1.0. Therefore, time weighting has no effect.

  3. Multiplying the data for each time by its normalized weighting.

See Also

| | | | | | |

Was this topic helpful?