Random walk
- ffpack.lsg.randomWalk.randomWalkUniform(numSteps, dim=1, randomSeed=None)
Generate load sequence by a random walk.
- Parameters
numSteps (integer) – Number of steps for generating.
dim (scalar, optional) – Data dimension.
randomSeed (integer, optional) – Random seed. If randomSeed is none or is not an integer, the random seed in global config will be used.
- Returns
rst – A 2d (numSteps by dim) matrix holding the coordinates of the position at each step.
- Return type
2d array
- Raises
ValueError – If the numSteps is less than 1 or the dim is less than 1.
Examples
>>> from ffpack.lsg import randomWalkUniform >>> rst = randomWalkUniform( 5 )
Autoregressive moving average
- ffpack.lsg.autoregressiveMovingAverage.arNormal(numSteps, obs, phis, mu, sigma, randomSeed=None)
Generate load sequence by an autoregressive model.
The white noise is generated by the normal distribution.
- Parameters
numSteps (integer) – Number of steps for generating.
obs (1d array) – Initial observed values.
phis (1d array) – Coefficients for the autoregressive model.
mu (scalar) – Mean of the white noise.
sigma (scalar) – Standard deviation of the white noise.
randomSeed (integer, optional) – Random seed. If randomSeed is none or is not an integer, the random seed in global config will be used.
- Returns
rst – Generated sequence includes the observed values.
- Return type
1d array
- Raises
ValueError – If the numSteps is less than 1. If lengths of obs and phis are not equal.
Examples
>>> from ffpack.lsg import arNormal >>> obs = [ 0, 1 ] >>> phis = [ 0.5, 0.3 ] >>> rst = arNormal( 500, obs, phis, 0, 0.5 )
- ffpack.lsg.autoregressiveMovingAverage.arimaNormal(numSteps, c, phis, thetas, mu, sigma, randomSeed=None)
Generate load sequence by an autoregressive integrated moving average model.
The white noise is generated by the normal distribution.
First-order diference is used in this function.
- Parameters
numSteps (integer) – Number of steps for generating.
c (scalar) – Mean of the series.
phis (1d array) – Coefficients for the autoregressive part.
thetas (1d array) – Coefficients for the white noise for the moving-average part.
mu (scalar) – Mean of the white noise.
sigma (scalar) – Standard deviation of the white noise.
randomSeed (integer, optional) – Random seed. If randomSeed is none or is not an integer, the random seed in global config will be used.
- Returns
rst – Generated sequence with the autoregressive integrated moving average model.
- Return type
1d array
- Raises
ValueError – If the numSteps is less than 1. If mean of the series is not a scalar. If the phis is empty. If the thetas is empty.
Examples
>>> from ffpack.lsg import arimaNormal >>> phis = [ 0.5, 0.3 ] >>> thetas = [ 0.8, 0.5 ] >>> rst = arimaNormal( 500, 0.0, phis, thetas, 0, 0.5 )
- ffpack.lsg.autoregressiveMovingAverage.armaNormal(numSteps, obs, phis, thetas, mu, sigma, randomSeed=None)
Generate load sequence by an autoregressive-moving-average model.
The white noise is generated by the normal distribution.
- Parameters
numSteps (integer) – Number of steps for generating.
obs (1d array) – Initial observed values, could be empty.
phis (1d array) – Coefficients for the autoregressive part.
thetas (1d array) – Coefficients for the white noise for the moving-average part.
mu (scalar) – Mean of the white noise.
sigma (scalar) – Standard deviation of the white noise.
randomSeed (integer, optional) – Random seed. If randomSeed is none or is not an integer, the random seed in global config will be used.
- Returns
rst – Generated sequence includes the observed values.
- Return type
1d array
- Raises
ValueError – If the numSteps is less than 1. If the phis is empty. If the thetas is empty.
Examples
>>> from ffpack.lsg import armaNormal >>> obs = [ 0, 1 ] >>> phis = [ 0.5, 0.3 ] >>> thetas = [ 0.8, 0.5 ] >>> rst = armaNormal( 500, obs, phis, thetas, 0, 0.5 )
- ffpack.lsg.autoregressiveMovingAverage.maNormal(numSteps, c, thetas, mu, sigma, randomSeed=None)
Generate load sequence by a moving-average model.
The white noise is generated by the normal distribution.
- Parameters
numSteps (integer) – Number of steps for generating.
c (scalar) – Mean of the series.
thetas (1d array) – Coefficients for the white noise in the moving-average model.
mu (scalar) – Mean of the white noise.
sigma (scalar) – Standard deviation of the white noise.
randomSeed (integer, optional) – Random seed. If randomSeed is none or is not an integer, the random seed in global config will be used.
- Returns
rst – Generated sequence with moving-average model.
- Return type
1d array
- Raises
ValueError – If the numSteps is less than 1. If mean of the series is not a scalar. If the thetas is empty.
Examples
>>> from ffpack.lsg import maNormal >>> thetas = [ 0.8, 0.5 ] >>> rst = maNormal( 500, 0, thetas, 0, 0.5 )
Sequence from spectrum
- ffpack.lsg.sequenceFromSpectrum.spectralRepresentation(fs, time, freq, psd, freqBandwidth=None, randomSeed=None)
Generate a sequence from a given power spectrum density with spectral representation method.
- Parameters
fs (scalar) – Sampling frequency.
time (scalar) – Total sampling time.
freq (1darray) – Frequency array for psd. The freq array should be in equally spaced increasing.
psd (1darray) – Power spectrum density array.
freqBandwidth (scalar, optional) – Frequency bandwidth used to generate the time series from psd. Default to None, every frequency in freq will be used.
randomSeed (integer, optional) – Random seed. If randomSeed is none or is not an integer, the random seed in global config will be used.
- Returns
ts (1darray) – Array containing all the time data for the time series.
amps (1darray) – Amplitude array containing the amplitudes of the time series corresponding to ts.
- Raises
ValueError – If the fs or time is not a scalar. If freq or psd is not a 1darray or has less than 3 elements. If freq and psd are in different lengths. If freq contains negative elements. If freq is not equally spaced increasing.
Examples
>>> from ffpack.lsg import spectralRepresentation >>> fs = 100 >>> time = 10 >>> freq = [ 0, 0.1, 0.2, 0.3, 0.4, 0.5 ] >>> psd = [ 0.01, 2, 0.05, 0.04, 0.01, 0.03 ] >>> ts, amps = spectralRepresentation( fs, time, freq, psd, freqBandwidth=None )