sample_pdf

nbi_stat.sample_pdf(y, x, cdf)[source]

Sample a PDF given by the table of the CDF

Example

>>> xev = np.linspace(0,10,11)
>>> cdf = eval_cdf(lambda x: x**2, xev
>>> x   = sample_pdf(np.random.uniform(size=100),xev,cdf)
Parameters:
  • y (scalar or array-like, float) – Uniformly distributed random variable

  • x (array-like) – Points where the CDF is evaluated

  • cdf (array-like) – CDF evaluated at x

Returns:

x – Random variable drawn from the PDF

Return type:

scalar or array-like, float

See also

eval_cdf