Post · 3 min read· pp. 997–999

aerosandbox.tools.statistics.time_series_uncertainty_quantification

Attributes

Functions

estimate_noise_standard_deviation(data[, estimator_order])Estimates the standard deviation of the random noise in a time-series dataset.
bootstrap_fits(x, y[, x_noise_stdev, y_noise_stdev, ...])Bootstraps a time-series dataset and fits splines to each bootstrap resample.

Module Contents

aerosandbox.tools.statistics.time_series_uncertainty_quantification.estimate_noise_standard_deviation(data, estimator_order=None) : Estimates the standard deviation of the random noise in a time-series dataset.

code
Relies on several assumptions:

- The noise is normally-distributed and independent between samples (i.e. white noise).
- The noise is stationary and homoscedastic (i.e., the noise standard deviation is constant).
- The noise is uncorrelated with the signal.
- The sample rate of the data is significantly higher than the highest-frequency component of the signal. (In
  :   practice, this ratio need not be more than ~5:1, if higher-order estimators are used. At a minimum, however,
      this ratio must be greater than 2:1, corresponding to the Nyquist frequency.)

The algorithm used in this function is a highly-optimized version of the math described in this repository,
part of an upcoming paper: <https://github.com/peterdsharpe/aircraft-polar-reconstruction-from-flight-test>

Parameters:
:   - **data** (*aerosandbox.numpy.ndarray*) – A 1D NumPy array of time-series data.
    - **estimator\_order** (*int*) – The order of the estimator to use. Higher orders are generally more accurate, up to the
      point where sample error starts to dominate. If None, a reasonable estimator order will be chosen automatically.

Return type:
:   float

Returns: An estimate of the standard deviation of the data’s noise component.

aerosandbox.tools.statistics.time_series_uncertainty_quantification.bootstrap_fits(x, y, x_noise_stdev=0.0, y_noise_stdev=None, n_bootstraps=2000, fit_points=300, spline_degree=3, normalize=None) : Bootstraps a time-series dataset and fits splines to each bootstrap resample.

code
Parameters:
:   - **x** (*aerosandbox.numpy.ndarray*) – The independent variable (e.g., time) of the dataset. A 1D NumPy array.
    - **y** (*aerosandbox.numpy.ndarray*) – The dependent variable (e.g., altitude) of the dataset. A 1D NumPy array.
    - **n\_bootstraps** (*int*) – The number of bootstrap resamples to create.
    - **fit\_points** (*Union**[**int**,* *Iterable**[**float**]**,* *None**]*) –

      An optional variable that determines what to do with the splines after they are fit:

      - If an integer, the splines will be evaluated at a linearly-spaced vector of points between the minimum
        :   and maximum x-values of the dataset, with the number of points equal to fit\_points. This is the default.
      - If an iterable of floats (e.g. a 1D NumPy array), the splines will be evaluated at those points.
      - If None, the splines won’t be evaluated, and instead the splines are returned directly.
    - **spline\_degree** (*int*) – The degree of the splines to fit.
    - **normalize** (*bool*) –

      Whether or not to normalize the data before fitting. If True, the data will be normalized to
      the range [0, 1] before fitting, and the splines will be un-normalized before being returned. If False,
      the data will not be normalized before fitting.

      - If None (the default), the data will be normalized if and only if fit\_points is not None.
    - **x\_noise\_stdev** (*Union**[**None**,* *float**]*) –
    - **y\_noise\_stdev** (*Union**[**None**,* *float**]*) –

Return type:
:   Union[Tuple[aerosandbox.numpy.ndarray, aerosandbox.numpy.ndarray], List[[aerosandbox.tools.pretty\_plots.utilities.natural\_univariate\_spline.NaturalUnivariateSpline](/u/f6bcb5d3cbc8f79b#aerosandbox-tools-pretty-plots-utilities-natural-univariate-spline-naturalunivariatespline)]]

Returns: One of the following, depending on the value of fit\_points:

> - If fit\_points is an integer or array, then this function returns a tuple of NumPy arrays:
>
>   > - x\_fit: A 1D NumPy array with the x-values at which the splines were evaluated.
>   > - y\_bootstrap\_fits: A 2D NumPy array of shape (n\_bootstraps, len(x\_fit)) with the y-values of the
>   >   :   splines evaluated at each bootstrap resample and at each x-value.
> - If fit\_points is None, then this function returns a list of n\_bootstraps splines, each of which is a
>   :   NaturalUnivariateSpline, which is a subclass of scipy.interpolate.UnivariateSpline with more sensible
>       extrapolation.

aerosandbox.tools.statistics.time_series_uncertainty_quantification.N = 1000