empirical_distribution

snippets.empirical_distribution.normalize_cdf(cdf: TensorLike, tol: float | None = None) ndarray

Normalize a cumulative distribution function between 0 and 1 after validation.

Parameters:
  • cdf – Cumulative distribution function to normalize.

  • tol – If given, the maximum acceptable difference for the first value of cdf to differ from 0 and the last value to differ from 1. Discrepancies may arise, for example, due to numerical errors incurred integrating a probability distribution function to obtain cdf.

Returns:

Normalized cumulative distribution function.

snippets.empirical_distribution.sample_empirical_cdf(x: TensorLike, cdf: TensorLike, size: int | Tuple[int] | None = None, kind: str = 'linear', random_state: RandomState | None = None, tol: float = 1e-09) ndarray

Sample from a univariate empirical cumulative distribution function using interpolation of the inverse cumulative distribution function.

Parameters:
  • x – Ordered vector of random variable values corresponding to cdf values.

  • cdf – Cumulative distribution function values corresponding to x values.

  • size – Sample size to draw.

  • kind – Interpolation method to use (see scipy.interpolate.inter1pd for details).

  • random_state – Random number generator state.

  • tol – Tolerance for normalizing cdf (see normalize_cdf() for details).

Returns:

Sample the desired size.

snippets.empirical_distribution.sample_empirical_pdf(x: TensorLike, pdf: TensorLike, size: int | Tuple[int] | None = None, kind: str = 'linear', random_state: RandomState | None = None, tol: float = 0) ndarray

Sample from a univariate empirical probability distribution function using interpolation of the inverse probability distribution function.

Parameters:
  • x – Ordered vector of random variable values corresponding to pdf values.

  • pdf – Probability distribution function values corresponding to x values.

  • size – Sample size to draw.

  • kind – Interpolation method to use (see scipy.interpolate.inter1pd for details).

  • random_state – Random number generator state.

  • tol – Maximum acceptable difference for the integrated cumulative distribution function to differ from 0 and the last value to differ from 1. Discrepancies may arise, for example, due to numerical errors incurred integrating pdf (see normalize_cdf() for details).

Returns:

Sample the desired size.