Beta-Sigma API

BSBase (Base class for BSEqSamp and BSArbSamp)

class PyAstronomy.pyasl.BSBase

Functionality to estimate noise from equidistantly and arbitrarily sampled data.

Methods

estimateStdMAD(x, mode)

Estimate standard deviation based on median absolute deviation (MAD)

meanUnbStd(x)

Mean and (unbiased) standard deviation of the mean.

stdUnbiased(y)

Get unbiased estimate of the standard deviation and its standard deviation.

stdc4(n)

Calculate c4 factor.

subsetIndexDissection(ndp, N, j)

Find array indices of (N+2)-length subsets.

subsetIndices(cd)

Compose indices sets defining the subsets to construct the beta sample.

variance(x, mode)

Estimate variance from sample

_checkJP(j)

Check validity of specified jump parameter.

_checkN(N)

Check validity of specified order of approximation.

estimateStdMAD(x, mode)

Estimate standard deviation based on median absolute deviation (MAD)

Parameters
xarray

Sample from which to determine the standard deviation.

modestring, {zm, em}

If ‘zm’, the population median is assumed to be zero. If ‘em’, the population median is estimated as the sample median.

Returns
stdfloat

Estimate of the standard deviation

meanUnbStd(x)

Mean and (unbiased) standard deviation of the mean.

Parameters
xarray

Sampe from which to calculate mean and std

Returns
mean, stdfloats

Mean and unbiased standard deviation of the mean

stdUnbiased(y)

Get unbiased estimate of the standard deviation and its standard deviation.

Parameters
yarray

Sample from which to estimate standard deviation.

Returns
Stdfloat

Unbiased estimate of the standard deviation.

Std of stdfloat

Standard deviation of the unbiased standard deviation estimator.

stdc4(n)

Calculate c4 factor.

The c4 factor is required to obtain an unbiased estimator for the standard deviation.

It is proportional to the factor B used in Kenney 1940, who started from a slightly different definition of the sample variance.

Parameters
nint

Number of points in the sample

Returns
c4, ln(c4)float

The c4 factor and its natural logarithm.

subsetIndexDissection(ndp, N, j)

Find array indices of (N+2)-length subsets.

Here, (N+2)-sized sets of indices are constructed, which are required in the construction of the beta sample.

Parameters
ndpint

Number of available data points

Nint

Last order of the Taylor series taken into account. Chunk length will be N+2.

jint

Jump parameter (>0)

Returns
k-indiceslist

A list holding N+2 elements. Each element of the list is an array holding the indices of the data point no. one, two, …, N+2 of the subsets required to construct the beta sample.

subsetIndices(cd)

Compose indices sets defining the subsets to construct the beta sample.

Parameters
cdlist

The output of subsetIndexDissection

Returns
Subset indices2d array

A 2d-array holding the indices of all subsets, arranged so that result[i,::] holds the N+2 indices pertaining to the i-th subset.

variance(x, mode)

Estimate variance from sample

Parameters
xarray

sample

modestring, {n, nmo}

Estimator to use: ‘n’ for 1/n version with zero mean (not estimated) and ‘nmo’ for 1/(n-1)

BSEqSamp (equidistant sampling)

class PyAstronomy.pyasl.BSEqSamp

Methods

betaSigma(y, N, j[, ignoreNaN, returnMAD, ibs])

Estimate standard deviation of noise term in data set y.

estimateStdMAD(x, mode)

Estimate standard deviation based on median absolute deviation (MAD)

getBetaSample(y, N, j)

Construct the beta sample.

getBetaSampleShift(y, N, j)

Construct beta sample using shifting procedure.

get_ak(N)

Calculate the required coefficients (a_k)

get_rhok(N)

Calculate (auto)correlation function for beta sample

meanUnbStd(x)

Mean and (unbiased) standard deviation of the mean.

stdUnbiased(y)

Get unbiased estimate of the standard deviation and its standard deviation.

stdc4(n)

Calculate c4 factor.

subsetIndexDissection(ndp, N, j)

Find array indices of (N+2)-length subsets.

subsetIndices(cd)

Compose indices sets defining the subsets to construct the beta sample.

variance(x, mode)

Estimate variance from sample

betaSigma(y, N, j, ignoreNaN=True, returnMAD=False, ibs=False)

Estimate standard deviation of noise term in data set y.

It is explicitly assumed that the data are equidistantly sampled.

Attribute

Type

Meaning

betaSample

array

The beta sample

estimates

dict

Summary of the estimates obtained from the beta sample (bs).

“s2E”: variance estimate of the bs (expectation value of zero), “s2Evar”: variance of s2E

“sE”: Estimate of std of bs, “sEstd”: Std of sE

“s2”: variance estimate of the bs (mean estimated from bs), “s2var”: variance of s2, “s”: sqrt(s2)

“sME”: Standard deviation based on MAD with zero expectation, “sMEstd”: Estimation of std of sME

“sM”: Standard deviation based on MAD with median estimated from bs, “sMEstd”: Estimation of std of sM

Parameters
yarray

Data values from which to estimate standard deviation of noise.

Nint

Last order of the Taylor series to be taken into account.

jint

Jump parameter

ignoreNaNboolean, optional

If True (default), NaN values in the beta sample are ignored in the calculation.

returnMADboolean, optional

If True, the estimate obtained using the MAD is returned instead of that of the MVU estimator (default is False). The standard error is estimated by scaling the standard deviation of the MVU estimator by a factor of 1.64.

ibsboolean, optional

If True, an independent beta sample is constructed. Default is False.

Returns
Estimate of STD in beta sample and the STD of the estimate: float, float

The standard deviation determined in the beta sample. Non-robust estimates sE and sEstd if returnMAD is False (default) or robust estimates sME and sMEstd if returnMAD is True. The estimates attribute holds a more comprehensive summary of the estimates.

getBetaSample(y, N, j)

Construct the beta sample.

Parameters
yarray

Values from which to estimate noise

Nint

Last order of the Taylor series taken into account

jint

Jump parameter (>0)

Returns
Beta samplearray

An array holding all available beta values.

getBetaSampleShift(y, N, j)

Construct beta sample using shifting procedure.

Parameters
yarray

Values from which to estimate noise

Nint

Last order of the Taylor series taken into account

jint

Jump parameter (>0)

Returns
Beta samplearray

An array holding all available beta values.

get_ak(N)

Calculate the required coefficients (a_k)

Parameters
Nint

Order of approximation

Returns
akarray

The coefficients

get_rhok(N)

Calculate (auto)correlation function for beta sample

Parameters
Nint

Order of approximation

Returns
correlation functionarray

Correlation function

BSArbSamp (arbitrary sampling)

class PyAstronomy.pyasl.BSArbSamp

Estimate noise in equidistantly sampled data.

Methods

betaSigma(x, y, N, j[, ignoreNaN, ...])

Estimate standard deviation of noise term in data set y.

estimateStdMAD(x, mode)

Estimate standard deviation based on median absolute deviation (MAD)

getBetaSample(x, y, N, j)

Combine data points to calculate beta values.

getBetaSampleShift(x, y, N, j)

Construct beta sample using shifting procedure.

getCoeffsArbSamp(t[, gamma])

Calculate coefficients (ak) for arbitrary sampling.

meanUnbStd(x)

Mean and (unbiased) standard deviation of the mean.

stdUnbiased(y)

Get unbiased estimate of the standard deviation and its standard deviation.

stdc4(n)

Calculate c4 factor.

subsetIndexDissection(ndp, N, j)

Find array indices of (N+2)-length subsets.

subsetIndices(cd)

Compose indices sets defining the subsets to construct the beta sample.

variance(x, mode)

Estimate variance from sample

betaSigma(x, y, N, j, ignoreNaN=True, returnMAD=False, ibs=False)

Estimate standard deviation of noise term in data set y.

In this implementation, arbitrary sampling is taken into account.

The method assigns the following attributes, which may be accessed after execution to work with the result:

Attribute

Type

Meaning

betaSample

array

The beta sample

estimates

dict

Summary of the estimates obtained from the beta sample (bs).

“s2E”: variance estimate of the bs (expectation value of zero), “s2Evar”: variance of s2E

“sE”: Estimate of std of bs, “sEstd”: Std of sE

“s2”: variance estimate of the bs (mean estimated from bs), “s2var”: variance of s2, “s”: sqrt(s2)

“sME”: Standard deviation based on MAD with zero expectation, “sMEstd”: Estimation of std of sME

“sM”: Standard deviation based on MAD with median estimated from bs, “sMEstd”: Estimation of std of sM

Parameters
xarray

Sampling of the data.

yarray

Data values from which to estimate standard deviation of noise.

Nint

Last order of the Taylor series to be taken into account.

jint, optional

Jump parameter (default is one, i.e., consecutive data points are combined to estimate the noise).

ignoreNaNboolean, optional

If True (default), NaN values in the beta sample are ignored in the calculation.

returnMADboolean, optional

If True, the estimate obtained using the MAD is returned instead of that of the MVU estimator (default is False). The standard error is estimated by scaling the standard deviation of the MVU estimator by a factor of 1.64.

ibsboolean, optional

If True, an independent beta sample is constructed. Default is False.

Returns
Estimate of STD in beta sample and the STD of the estimate: float, float

The standard deviation determined in the beta sample. Non-robust estimates sE and sEstd if returnMAD is False (default) or robust estimates sME and sMEstd if returnMAD is True. The estimates attribute holds a more comprehensive summary of the estimates.

getBetaSample(x, y, N, j)

Combine data points to calculate beta values.

Parameters
xarray

Sampling of data

yarray

Values from which to estimate noise

Nint

Last order of the Taylor series taken into account

jint

Jump parameter (>0)

Returns
Betasarray

An array holding all available beta values.

getBetaSampleShift(x, y, N, j)

Construct beta sample using shifting procedure.

Parameters
x, yarray

Values from which to estimate noise

Nint

Last order of the Taylor series taken into account

jint

Jump parameter (>0)

Returns
Beta samplearray

An array holding all available beta values.

getCoeffsArbSamp(t, gamma=1.0)

Calculate coefficients (ak) for arbitrary sampling.

Parameters
tarray

Sampling instants of the subset.

gammafloat, optional

Scaling of the coefficients (default is one).

Returns
akarray

Set of coefficients.

SampCorr (sample correlation)

class PyAstronomy.pyasl.SampCorr

Methods

get_nb(N, ss)

BH46 Eq.

get_nvr

get_r

get_rhok

getak

get_nb(N, ss)

BH46 Eq. 14