Skip to main content
`Ctrl`+`K`

# Distribution

class astropy.uncertainty.Distribution(samples)

  Bases: `object`

  A scalar value or array values with associated uncertainty distribution.

  This object will take its exact type from whatever the `samples` argument is. In general this is expected to be `NdarrayDistribution` for |ndarray| input, and, e.g., `QuantityDistribution` for a subclass such as |Quantity|. But anything compatible with `numpy.asanyarray` is possible (generally producing `NdarrayDistribution`).

  See also: https://docs.astropy.org/en/stable/uncertainty/

  Parameters:
    samples numpy:array_like

      The distribution, with sampling along the trailing axis. If 1D, the sole dimension is used as the sampling axis (i.e., it is a scalar distribution). If an |ndarray| or subclass, the data will not be copied unless it is not possible to take a view (generally, only when the strides of the last axis are negative).

  Attributes Summary

  `distribution` |
  `dtype` |
  `n_samples` | The number of samples of this distribution.

  Methods Summary

  `astype`(dtype, *args, **kwargs) |
  `pdf_histogram`(**kwargs) | Compute histogram over the samples in the distribution.
  `pdf_mad`([out]) | The median absolute deviation of this distribution.
  `pdf_mean`([dtype, out]) | The mean of this distribution.
  `pdf_median`([out]) | The median of this distribution.
  `pdf_percentiles`(percentile, **kwargs) | Compute percentiles of this Distribution.
  `pdf_smad`([out]) | The median absolute deviation of this distribution rescaled to match the standard deviation for a normal distribution.
  `pdf_std`([dtype, out, ddof]) | The standard deviation of this distribution.
  `pdf_var`([dtype, out, ddof]) | The variance of this distribution.

  Attributes Documentation

  distribution
  dtype
  n_samples

    The number of samples of this distribution. A single `int`.

  Methods Documentation

  astype(dtype, *args, **kwargs)
  pdf_histogram(**kwargs)

    Compute histogram over the samples in the distribution.

    Parameters:
      All keyword arguments are passed into `astropy.stats.histogram`. Note
      That some of these options may not be valid for some multidimensional
      distributions.
    Returns:
      hist `array`

        The values of the histogram. Trailing dimension is the histogram dimension.

      bin_edges `array` of `dtype` `python:float`

        Return the bin edges `(length(hist)+1)`. Trailing dimension is the bin histogram dimension.

  pdf_mad(out=None)

    The median absolute deviation of this distribution.

    Parameters:
      out `array`, optional

        Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output, but the type (of the output) will be cast if necessary.

  pdf_mean(dtype=None, out=None)

    The mean of this distribution.

    Arguments are as for `numpy.mean`.

  pdf_median(out=None)

    The median of this distribution.

    Parameters:
      out `array`, optional

        Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output, but the type (of the output) will be cast if necessary.

  pdf_percentiles(percentile, **kwargs)

    Compute percentiles of this Distribution.

    Parameters:
      percentile `python:float` or `array` of `python:float` or `Quantity`

        The desired percentiles of the distribution (i.e., on [0,100]). `Quantity` will be converted to percent, meaning that a `dimensionless_unscaled` `Quantity` will be interpreted as a quantile.

      Additional keywords are passed into `numpy.percentile`.
    Returns:
      percentiles `Quantity` [:ref: ‘dimensionless’]

        The `fracs` percentiles of this distribution.

  pdf_smad(out=None)

    The median absolute deviation of this distribution rescaled to match the standard deviation for a normal distribution.

    Parameters:
      out `array`, optional

        Alternative output array in which to place the result. It must have the same shape and buffer length as the expected output, but the type (of the output) will be cast if necessary.

  pdf_std(dtype=None, out=None, ddof=0)

    The standard deviation of this distribution.

    Arguments are as for `numpy.std`.

  pdf_var(dtype=None, out=None, ddof=0)

    The variance of this distribution.

    Arguments are as for `numpy.var`.