mle_fit

nbi_stat.mle_fit(f, data, p0, *args, **kwargs)[source]

Do an MLE estimate of parameters of the PDF given data yield.

Parameters:
  • f (callable) – The PDF

  • x (array-like to (array-like,array-like)) –

    The observations.

    If a single array-like argument is given, we perform a regular MLE fit.

    If two array-like arguments are given, perform a binned MLE fit. The first is assumed to be the bin boundaries, while the second is assumed to contain on of

    • raw counts (density=False)

    • number density (dN/dx), by setting density=True

    • normalized number density (1/N dN/dx) by setting density=True and passing N=N where N is the total normalization (e.g., number of observations) of the sample.

  • p0 (array-like, size N) – The initial guess of the parameter values. Note, if extended=True, then an additional first parameter nu must be passed in addition to the regular PDF parameters.

  • full_output (bool) – If set to true, return full minimizer output too

  • logpdf (bool) – If set to true, assume f returns the logarithm of the PDF

  • poisson (bool) – Only for binned MLE. If true, assume Poisson statistics. That is, f gives the mean of a Poisson distribution, and we evaulate the probability of n given that mean.

  • extended (bool) – If true, perform an extended maximum likelihood estimate. Note, if this is true, then the first parameter _must_ be the estimated abundance nu.

  • normalized (bool) – If false, and extended=True assume the PDF is not normalized and calculate the normalization and include that in the extended logarithmic likelihood function.

  • cdf (bool) – Only for binned MLE. The passed function is assumed to be the cumulative density function.

  • density (bool, int, float) – Only for binned MLE. If True, then assume number density (dN/dx) is passed as second data argument. If a number not equal to 1, it is the total normalisation of the normalized number density (1/N dN/dx) passed in the second data argument.

  • *args (tuple) – Arguments passed on to scipy.optimize.minimize

  • **kwargs (dict) – Keyword arguments passed on to scipy.optimize.minimize

Returns:

  • p (array-like, size N) – MLE of the parameter values

  • cov (array-like size N*N) – Covariance matrix of parameters (inverse Hessian) if available from the minimizer, otherwise Non

  • opt (dict-like) – Full minimizer output of full_output is true

See also

minimize_llh, llh, binned_llh