Random
All functions · nseries package
Rand
func (s Series) Rand(factor float64) Series
Rand modifies each element x by a pseudo-random number in the half-open range [-0.5, 0.5) multiplied by the provided factor. It can be used to generate a random walk of values. TODO – Think about whether to leave the first value unchanged?
RandNorm
func (s Series) RandNorm(n int, factor float64) Series
RandNorm modifies each element x by a normally-distributed pseudo-random amount based on the distribution of the previous n values. If n > 0, the first n-1 values in the series will be unmodified (since we need n values to determine the mean and standard deviation). If n <= 0, we sample the whole range to determine the mean and standard deviation to apply.
factor is a multiplier of the rolling standard deviation, not an absolute amount: each perturbation is a standard normal draw times the n-bar standard deviation times factor.