power1d.noise

One-dimensional noise models.

The figure below provides overview of all noise types. Details regarding reach are listed below.

(Source code, png, hires.png, pdf)

../_images/all_noise.png

Additive

power1d.noise.Additive(*noise_models)[source]

Additive model (sum of two or more other noise types.)

Arguments:

A sequence of power1d.noise models (must have the same shape: (J,Q) )

Example:

import power1d

noise0  = power1d.noise.SmoothGaussian( J=8, Q=501, mu=0, sigma=1.0, fwhm=100 )
noise1  = power1d.noise.Gaussian( J=8, Q=501, mu=0, sigma=0.1 )
noise   = power1d.noise.Additive(noise0, noise1)
noise.plot()

(Source code, png, hires.png, pdf)

../_images/noise-1.png

ConstantGaussian

power1d.noise.ConstantGaussian(J=1, Q=101, mu=0, sigma=1)[source]

Gaussian-distributed constant continuum noise.

Each of the J continua has a constant value, and these values are distributed normally according to mu and sigma.

Arguments:

J —- sample size (int) (default 1)

Q —- continuum size (int) (default 101)

x0 —- minimum value (float or int) (default 0)

x1 —- maximum value (float or int) (default 1)

Example:

import power1d

noise   = power1d.noise.ConstantGaussian( J=8, Q=101, mu=0, sigma=1.0 )
noise.plot()

(Source code, png, hires.png, pdf)

../_images/noise-2.png

ConstantUniform

power1d.noise.ConstantUniform(J=1, Q=101, x0=0, x1=1)[source]

Uniformly-distributed constant continuum noise.

Each of the J continua has a constant value, and these values are distributed uniformly between x0 and x1.

Arguments:

J —- sample size (int) (default 1)

Q —- continuum size (int) (default 101)

x0 —- mean (float or int) (default 0)

x1 —- standard deviation (float or int) (default 1)

Example:

import power1d

noise   = power1d.noise.ConstantUniform( J=8, Q=101, x0=-0.5, x1=1.3 )
noise.plot()

(Source code, png, hires.png, pdf)

../_images/noise-3.png

Gaussian

power1d.noise.Gaussian(J=1, Q=101, mu=0, sigma=1)[source]

Uncorrelated Gaussian noise.

Arguments:

J —- sample size (int) (default 1)

Q —- continuum size (int) (default 101)

mu —- mean (float or int) (default 0)

sigma —- standard deviation (float or int) (default 1)

Example:

import power1d

noise   = power1d.noise.Gaussian( J=8, Q=101, mu=0, sigma=1.0 )
noise.plot()

(Source code, png, hires.png, pdf)

../_images/noise-4.png

Mixture

power1d.noise.Mixture(*noise_models)[source]

Noise mixture model (mixture of noise types in a fixed ratio)

Arguments:

A sequence of power1d.noise models (must have the same shape: (,Q) )

Example:

import power1d

noise0  = power1d.noise.SmoothGaussian( J=3, Q=101, mu=3, sigma=1.0, fwhm=20 )
noise1  = power1d.noise.Gaussian( J=5, Q=101, mu=-3, sigma=1.0 )
noise   = power1d.noise.Mixture(noise0, noise1)
noise.plot()

(Source code, png, hires.png, pdf)

../_images/noise-5.png

Scaled

power1d.noise.Scaled(noise, scale)[source]

Scaled noise model.

Arguments:

noise —- a power1d.noise object

scale —- a numpy array or a power1d.primitive object

Example:

import numpy as np
import power1d

Q       = 101
noise0  = power1d.noise.Gaussian( J=5, Q=Q, mu=0, sigma=1.0 )
scale   = np.linspace(0, 1, Q)
noise   = power1d.noise.Scaled(noise0, scale)
noise.plot()

(Source code, png, hires.png, pdf)

../_images/noise-6.png

SignalDependent

power1d.noise.SignalDependent(noise, signal, fn=None)[source]

Signal-dependent noise model.

Arguments:

noise —- a power1d.noise object

signal —- a numpy array or a power1d.signal object

fn —- an arbitrary function of noise and signal (default fn = lambda n,s: n + (n * s))

Example:

import numpy as np
import power1d

Q       = 101
noise0  = power1d.noise.Gaussian( J=5, Q=Q, mu=0, sigma=1.0 )
signal  = power1d.geom.GaussianPulse(Q=Q, q=60, amp=3, fwhm=15)
fn      = lambda n,s: n + (n * s**3)
noise   = power1d.noise.SignalDependent(noise0, signal, fn)
noise.plot()

(Source code, png, hires.png, pdf)

../_images/noise-7.png

power1d.noise.Skewed(J=8, Q=101, mu=0, sigma=1, alpha=0)[source]

Skewed noise.

Warning

Skewed distributions are approximate and may not be consistent with theoretical solutions. In particular the their maximum likelihoods are not mu. In power1d skewed distribution are meant only to be used as tools to approximate experimentally observed skewed noise and / or for exploratory purposes (i.e. to examine power changes associated with roughly skewed distributions).

Arguments:

J —- sample size (int) (default 1)

Q —- continuum size (int) (default 101)

mu —- mean (float or int) (default 0)

sigma —- standard deviation (float or int) (default 1)

alpha —- skewness (float or int) (default 0)

Modified from a StackOverflow contribution by jamesj629:

http://stackoverflow.com/questions/36200913/generate-n-random-numbers-from-a-skew-normal-distribution-using-numpy

Example:

import power1d

noise   = power1d.noise.Skewed( J=8, Q=101, mu=0, sigma=1.0, alpha=5 )
noise.plot()

(Source code, png, hires.png, pdf)

../_images/noise-8.png

SmoothGaussian

power1d.noise.SmoothGaussian(J=1, Q=101, mu=0, sigma=1, fwhm=20, pad=False)[source]

Smooth (correlated) Gaussian noise.

Arguments:

J —- sample size (int) (default 1)

Q —- continuum size (int) (default 101)

mu —- mean (float or int) (default 0)

sigma —- standard deviation (float or int) (default 1)

fwhm —- smoothness (float or int) (default 20); this is the full-width-at-half-maximum of a Gaussian kernel which is convolved with uncorrelated Gaussian noise; the resulting smooth noise is re-scaled to unit variance

pad —- whether to pad continuum when smoothing (True or False) (default False); unpadded noise has the same value at the beginning and end of the continuum

Example:

import power1d

noise   = power1d.noise.SmoothGaussian( J=8, Q=101, mu=0, sigma=1.0, fwhm=25, pad=False )
noise.plot()

(Source code, png, hires.png, pdf)

../_images/noise-9.png

SmoothSkewed

power1d.noise.SmoothSkewed(J=8, Q=101, mu=0, sigma=1, fwhm=20, pad=True, alpha=0)[source]

Smooth, skewed noise.

Warning

This smooth skewed distribution implementation is preliminary and will only accept skewness parameter “alpha” values in the range (1, 5). To skew in the opposite direction use (-5, -1). Note that skewed distributions are approximate and may not be consistent with theoretical solutions.

Arguments:

J —- sample size (int) (default 1)

Q —- continuum size (int) (default 101)

mu —- mean (float or int) (default 0)

sigma —- standard deviation (float or int) (default 1)

fwhm —- smoothness (float or int) (default 20); this is the full-width-at-half-maximum of a Gaussian kernel which is convolved with uncorrelated Gaussian noise; the resulting smooth noise is re-scaled to unit variance

pad —- whether to pad continuum when smoothing (True or False) (default False); unpadded noise has the same value at the beginning and end of the continuum

alpha —- skewness (float or int between -5 and 5) (default 0)

Example:

import power1d

noise   = power1d.noise.SmoothSkewed( J=8, Q=101, mu=0, sigma=1.0, fwhm=25, pad=False, alpha=-3 )
noise.plot()

(Source code, png, hires.png, pdf)

../_images/noise-10.png

Uniform

power1d.noise.Uniform(J=1, Q=101, x0=0, x1=1)[source]

Uniform noise.

Arguments:

J —- sample size (int) (default 1)

Q —- continuum size (int) (default 101)

x0 —- minimum value (float or int) (default 0)

x1 —- maximum value (float or int) (default 1)

Example:

import power1d

noise   = power1d.noise.Uniform( J=8, Q=101, x0=0, x1=1.0 )
noise.plot()

(Source code, png, hires.png, pdf)

../_images/noise-11.png