rate_estimation module

rate_estimation.calculate_alphabetsoup_rate_posteriors(rankingstatpdf, ln_likelihood_ratios, verbose=False, nsample=400000)[source]

FIXME: document this

rate_estimation.calculate_psignal_posteriors(rankingstatpdf, ln_likelihood_ratios, verbose=False, chain_file=None, nsample=400000)[source]

FIXME: document this

rate_estimation.calculate_psignal_posteriors_from_rate_samples(rankingstatpdf, ln_likelihood_ratios, nsample=100000, verbose=False)[source]

FIXME: document this

rate_estimation.calculate_rate_posteriors(rankingstatpdf, ln_likelihood_ratios, verbose=False, chain_file=None, nsample=400000)[source]

FIXME: document this

rate_estimation.confidence_interval_from_lnpdf(ln_pdf, confidence=0.95)[source]

Constructs a confidence interval based on a BinnedArray object containing a normalized 1-D PDF. Returns the tuple (mode, lower bound, upper bound).

rate_estimation.f_over_b(rankingstatpdf, ln_likelihood_ratios)[source]

For each sample of the ranking statistic, evaluate the ratio of the signal ranking statistic PDF to background ranking statistic PDF.

rate_estimation.ln_double_fac_table(N)[source]

Compute a look-up table giving

ln (2m - 1)!! (2n - 1)!!

for 0 <= m <= N, n + m = N.

rate_estimation.maximum_likelihood_rates(rankingstatpdf, ln_likelihood_ratios)[source]
rate_estimation.mean_from_lnpdf(ln_pdf)[source]
rate_estimation.median_from_lnpdf(ln_pdf)[source]
rate_estimation.moment_from_lnpdf(ln_pdf, moment, c=0.0)[source]
rate_estimation.rate_posterior_from_samples(samples)[source]

Construct and return a BinnedArray containing a histogram of a sequence of samples. If limits is None (default) then the limits of the binning will be determined automatically from the sequence, otherwise limits is expected to be a tuple or other two-element sequence providing the (low, high) limits, and in that case the sequence can be a generator.

rate_estimation.run_mcmc(n_walkers, n_dim, n_samples_per_walker, lnprobfunc, pos0=None, args=(), n_burn=100, verbose=False)[source]

A generator function that yields samples distributed according to a user-supplied probability density function that need not be normalized. lnprobfunc computes and returns the natural logarithm of the probability density, up to a constant offset. n_dim sets the number of dimensions of the parameter space over which the PDF is defined and args gives any additional arguments to be passed to lnprobfunc, whose signature must be:

ln(P) = lnprobfunc(X, *args)

where X is a numpy array of length n_dim.

The generator yields a total of n_samples_per_walker arrays each of which is n_walkers by n_dim in size. Each row is a sample drawn from the n_dim-dimensional parameter space.

pos0 is an n_walkers by n_dim array giving the initial positions of the walkers (this parameter is currently not optional). n_burn iterations of the MCMC sampler will be executed and discarded to allow the system to stabilize before samples are yielded to the calling code. A chain can be continued by passing the last return value as pos0 and setting n_burn = 0.

NOTE: the samples yielded by this generator are not drawn from the PDF independently of one another. The correlation length is not known at this time.

rate_estimation.variance_from_lnpdf(ln_pdf)[source]