# Bumps 0.9.1 documentation

## pdfwrapper - Model a probability density function

`DirectProblem` | Build model from negative log likelihood function f(p).
`PDF` | Build a model from a function.
`VectorPDF` | Build a model from a function.

Build a bumps model from a function.

The `PDF` class uses introspection to convert a negative log likelihood function nllf(m1,m2,…) into a `bumps.fitproblem.Fitness` class that has fittable parameters m1, m2, ….

There is no attempt to manage data or uncertainties, except that an additional plot function can be provided to display the current value of the function in whatever way is meaningful.

The note regarding user defined functions in `bumps.curve` apply here as well.

class bumps.pdfwrapper.DirectProblem(f, p0, bounds=None, dof=1, labels=None, plot=None)

  Bases: `object`

  Build model from negative log likelihood function f(p).

  Vector p of length n defines the initial value.

  bounds defines limiting values for p as [(p1_low, p1_high), (p2_low, p2_high), …]. If all parameters are have the same bounds, use bounds=np.tile([low,high],[n,1]).

  Unlike `PDF`, no parameter objects are defined for the elements of p, so all are fitting parameters.

  bounds()
  chisq()
  chisq_str()
  getp()
  has_residuals = False
  labels()
  model_parameters()
  model_reset()
  model_update()
  nllf(pvec=None)
  plot(p=None, fignum=None, figfile=None, view=None)

    Plot the model to the current figure. You only get one figure, but you can make it as complex as you want. This will be saved as a png on the server, and composed onto a results web page.

  randomize(n=None)
  setp(p)
  show()
  summarize()

class bumps.pdfwrapper.PDF(fn, name='', plot=None, dof=1, **kw)

  Bases: `object`

  Build a model from a function.

  This model can be fitted with any of the bumps optimizers.

  fn is a function that returns the negative log likelihood of seeing its input parameters.

  The fittable parameters are derived from the parameter names in the function definition, with name prepended to each parameter.

  The optional plot function takes the same arguments as fn, with an additional view argument which may be set from the bumps command line. If provide, it should provide a visual indication of the function value and uncertainty on the current matplotlib.pyplot figure.

  Additional keyword arguments are treated as the initial values for the parameters, or initial ranges if par=(min,max). Otherwise, the default is taken from the function definition (if the function uses par=value to define the parameter) or is set to zero if no default is given in the function.

  chisq()
  chisq_str()
  has_residuals = False
  nllf()

    Call self as a function.

  numpoints()

    Return the number of data points.

  parameters()

    return the parameters in the model.

    model parameters are a hierarchical structure of lists and dictionaries.

  plot(view=None)

    Plot the model to the current figure. You only get one figure, but you can make it as complex as you want. This will be saved as a png on the server, and composed onto a results web page.

class bumps.pdfwrapper.VectorPDF(fn, p, name='', plot=None, dof=1, labels=None, **kw)

  Bases: `object`

  Build a model from a function.

  This model can be fitted with any of the bumps optimizers.

  fn is a function that returns the negative log likelihood of seeing its input parameters.

  Vector p of length n defines the initial value. Unlike `PDF`, VectorPDF operates on a parameter vector p rather than individual parameters p1, p2, etc. Default parameter values p must be provided in order to determine the number of parameters.

  labels are the names of the individual parameters. If not present, the name for parameter k defaults to pk. Each label is prefixed by name.

  The optional plot function takes the same arguments as fn, with an additional view argument which may be set from the bumps command line. If provide, it should provide a visual indication of the function value and uncertainty on the current matplotlib.pyplot figure.

  Additional keyword arguments are treated as the initial values for the parameters, or initial ranges if par=(min,max). Otherwise, the default is taken from the function definition (if the function uses par=value to define the parameter) or is set to zero if no default is given in the function.

  chisq()
  chisq_str()
  has_residuals = False
  nllf()

    Call self as a function.

  numpoints()

    Return the number of data points.

  parameters()

    return the parameters in the model.

    model parameters are a hierarchical structure of lists and dictionaries.

  plot(view=None)

    Plot the model to the current figure. You only get one figure, but you can make it as complex as you want. This will be saved as a png on the server, and composed onto a results web page.

  residuals()

    Return residuals for current theory minus data.

    Used for Levenburg-Marquardt, and for plotting.