parameter - Optimization parameter definition

Alias Parameter alias.
BaseParameter Root of the parameter class, defining arithmetic on parameters
Constant An unmodifiable value.
Constraint Abstract base class for constraints.
ConstraintEQ Constraint operator ==
ConstraintGE Constraint operator >=
ConstraintGT Constraint operator >
ConstraintLE Constraint operator <=
ConstraintLT Constraint operator <
ConstraintNE Constraint operator !=
FreeVariables A collection of parameter sets for a group of models.
Function Delayed function evaluator.
IntegerParameter
OperatorAdd Parameter operator +
OperatorDiv Parameter operator /
OperatorMul Parameter operator *
OperatorPow Parameter operator **
OperatorSub Parameter operator -
Parameter A parameter is a symbolic value.
ParameterSet A parameter that depends on the model.
Reference Create an adaptor so that a model attribute can be treated as if it were a parameter.
current
fittable Return the list of fittable parameters in no paraticular order.
flatten
format Format parameter set for printing.
function Convert a function into a delayed evaluator.
randomize Set random values to the parameters in the parameter set, with values chosen according to the bounds.
substitute Return structure a with values substituted for all parameters.
summarize Return a stylized list of parameter names and values with range bars suitable for printing.
unique Return the unique set of parameters
varying Return the list of fitted parameters in the model.

Fitting parameter objects.

Parameters are a big part of the interface between the model and the fitting engine. By saving and retrieving values and ranges from the parameter, the fitting engine does not need to be aware of the structure of the model.

Users can also perform calculations with parameters, tying together different parts of the model, or different models.

class bumps.parameter.Alias(obj, attr, p=None, name=None)[source]

Bases: object

Parameter alias.

Rather than modifying a model to contain a parameter slot, allow the parameter to exist outside the model. The resulting parameter will have the full parameter semantics, including the ability to replace a fixed value with a parameter expression.

# TODO: how is this any different from Reference above?

parameters()[source]
update()[source]
class bumps.parameter.BaseParameter[source]

Bases: object

Root of the parameter class, defining arithmetic on parameters

bounds

Fit bounds

dev(std, mean=0, limits=None, sigma=None, mu=None)[source]

Allow the parameter to vary according to a normal distribution, with deviations from the mean added to the overall cost function for the model.

If mean is None, then it defaults to the current parameter value.

If limits are provide, then use a truncated normal distribution.

Note: sigma and mu have been replaced by std and mean, but are left in for backward compatibility.

discrete = False
fittable = False
fixed = True
format()[source]

Format the parameter, value and range as a string.

name = None
nllf()[source]

Return -log(P) for the current parameter value.

parameters()[source]
pdf(dist)[source]

Allow the parameter to vary according to any continuous scipy.stats distribution.

pm(*args)[source]

Allow the parameter to vary as value +/- delta.

pm(delta) -> [value-delta, value+delta]

pm(plus, minus) -> [value+minus, value+plus]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

pmp(*args)[source]

Allow the parameter to vary as value +/- percent.

pmp(percent) -> [value*(1-percent/100), value*(1+percent/100)]

pmp(plus, minus) -> [value*(1+minus/100), value*(1+plus/100)]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

range(low, high)[source]

Allow the parameter to vary within the given range.

residual()[source]

Return the z score equivalent for the current parameter value.

That is, the given the value of the parameter in the underlying distribution, find the equivalent value in the standard normal. For a gaussian, this is the z score, in which you subtract the mean and divide by the standard deviation to get the number of sigmas away from the mean. For other distributions, you need to compute the cdf of value in the parameter distribution and invert it using the ppf from the standard normal distribution.

soft_range(low, high, std)[source]

Allow the parameter to vary within the given range, or with Gaussian probability, stray from the range.

valid()[source]

Return true if the parameter is within the valid range.

class bumps.parameter.Constant(value, name=None)[source]

Bases: bumps.parameter.BaseParameter

An unmodifiable value.

bounds

Fit bounds

dev(std, mean=0, limits=None, sigma=None, mu=None)

Allow the parameter to vary according to a normal distribution, with deviations from the mean added to the overall cost function for the model.

If mean is None, then it defaults to the current parameter value.

If limits are provide, then use a truncated normal distribution.

Note: sigma and mu have been replaced by std and mean, but are left in for backward compatibility.

discrete = False
fittable = False
fixed = True
format()

Format the parameter, value and range as a string.

name = None
nllf()

Return -log(P) for the current parameter value.

parameters()
pdf(dist)

Allow the parameter to vary according to any continuous scipy.stats distribution.

pm(*args)

Allow the parameter to vary as value +/- delta.

pm(delta) -> [value-delta, value+delta]

pm(plus, minus) -> [value+minus, value+plus]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

pmp(*args)

Allow the parameter to vary as value +/- percent.

pmp(percent) -> [value*(1-percent/100), value*(1+percent/100)]

pmp(plus, minus) -> [value*(1+minus/100), value*(1+plus/100)]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

range(low, high)

Allow the parameter to vary within the given range.

residual()

Return the z score equivalent for the current parameter value.

That is, the given the value of the parameter in the underlying distribution, find the equivalent value in the standard normal. For a gaussian, this is the z score, in which you subtract the mean and divide by the standard deviation to get the number of sigmas away from the mean. For other distributions, you need to compute the cdf of value in the parameter distribution and invert it using the ppf from the standard normal distribution.

soft_range(low, high, std)

Allow the parameter to vary within the given range, or with Gaussian probability, stray from the range.

valid()

Return true if the parameter is within the valid range.

value
class bumps.parameter.Constraint[source]

Abstract base class for constraints.

class bumps.parameter.ConstraintEQ(a, b)

Bases: bumps.parameter.Constraint

Constraint operator ==

class bumps.parameter.ConstraintGE(a, b)

Bases: bumps.parameter.Constraint

Constraint operator >=

class bumps.parameter.ConstraintGT(a, b)

Bases: bumps.parameter.Constraint

Constraint operator >

class bumps.parameter.ConstraintLE(a, b)

Bases: bumps.parameter.Constraint

Constraint operator <=

class bumps.parameter.ConstraintLT(a, b)

Bases: bumps.parameter.Constraint

Constraint operator <

class bumps.parameter.ConstraintNE(a, b)

Bases: bumps.parameter.Constraint

Constraint operator !=

class bumps.parameter.FreeVariables(names=None, **kw)[source]

Bases: object

A collection of parameter sets for a group of models.

names is the set of model names.

The parameters themselves are specified as key=value pairs, with key being the attribute name which is used to retrieve the parameter set and value being a Parameter containing the parameter that is shared between the models.

In order to evaluate the log likelihood of all models simultaneously, the fitting program will need to call set_model with the model index for each model in turn in order to substitute the values from the free variables into the model. This allows us to share a common sample across multiple data sets, with each dataset having its own values for some of the sample parameters. The alternative is to copy the entire sample structure, sharing references to common parameters and creating new parameters for each model for the free parameters. Setting up these copies was inconvenient.

parameters()[source]

Return the set of free variables for all the models.

set_model(i)[source]

Set the reference parameters for model i.

class bumps.parameter.Function(op, *args, **kw)[source]

Bases: bumps.parameter.BaseParameter

Delayed function evaluator.

f.value evaluates the function with the values of the parameter arguments at the time f.value is referenced rather than when the function was invoked.

args
bounds

Fit bounds

dev(std, mean=0, limits=None, sigma=None, mu=None)

Allow the parameter to vary according to a normal distribution, with deviations from the mean added to the overall cost function for the model.

If mean is None, then it defaults to the current parameter value.

If limits are provide, then use a truncated normal distribution.

Note: sigma and mu have been replaced by std and mean, but are left in for backward compatibility.

discrete = False
fittable = False
fixed = True
format()

Format the parameter, value and range as a string.

kw
name = None
nllf()

Return -log(P) for the current parameter value.

op
parameters()[source]
pdf(dist)

Allow the parameter to vary according to any continuous scipy.stats distribution.

pm(*args)

Allow the parameter to vary as value +/- delta.

pm(delta) -> [value-delta, value+delta]

pm(plus, minus) -> [value+minus, value+plus]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

pmp(*args)

Allow the parameter to vary as value +/- percent.

pmp(percent) -> [value*(1-percent/100), value*(1+percent/100)]

pmp(plus, minus) -> [value*(1+minus/100), value*(1+plus/100)]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

range(low, high)

Allow the parameter to vary within the given range.

residual()

Return the z score equivalent for the current parameter value.

That is, the given the value of the parameter in the underlying distribution, find the equivalent value in the standard normal. For a gaussian, this is the z score, in which you subtract the mean and divide by the standard deviation to get the number of sigmas away from the mean. For other distributions, you need to compute the cdf of value in the parameter distribution and invert it using the ppf from the standard normal distribution.

soft_range(low, high, std)

Allow the parameter to vary within the given range, or with Gaussian probability, stray from the range.

valid()

Return true if the parameter is within the valid range.

value
class bumps.parameter.IntegerParameter(value=None, bounds=None, fixed=None, name=None, **kw)[source]

Bases: bumps.parameter.Parameter

bounds

Fit bounds

clip_set(value)

Set a new value for the parameter, clipping it to the bounds.

default(value, **kw)

Create a new parameter with the value and kw attributes, or return the existing parameter if value is already a parameter.

The attributes are the same as those for Parameter, or whatever subclass cls of Parameter is being created.

dev(std, mean=0, limits=None, sigma=None, mu=None)

Allow the parameter to vary according to a normal distribution, with deviations from the mean added to the overall cost function for the model.

If mean is None, then it defaults to the current parameter value.

If limits are provide, then use a truncated normal distribution.

Note: sigma and mu have been replaced by std and mean, but are left in for backward compatibility.

discrete = True
feasible()

Value is within the limits defined by the model

fittable = True
fixed = True
format()

Format the parameter, value and range as a string.

name = None
nllf()

Return -log(P) for the current parameter value.

parameters()
pdf(dist)

Allow the parameter to vary according to any continuous scipy.stats distribution.

pm(*args)

Allow the parameter to vary as value +/- delta.

pm(delta) -> [value-delta, value+delta]

pm(plus, minus) -> [value+minus, value+plus]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

pmp(*args)

Allow the parameter to vary as value +/- percent.

pmp(percent) -> [value*(1-percent/100), value*(1+percent/100)]

pmp(plus, minus) -> [value*(1+minus/100), value*(1+plus/100)]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

randomize(rng=None)

Set a random value for the parameter.

range(low, high)

Allow the parameter to vary within the given range.

residual()

Return the z score equivalent for the current parameter value.

That is, the given the value of the parameter in the underlying distribution, find the equivalent value in the standard normal. For a gaussian, this is the z score, in which you subtract the mean and divide by the standard deviation to get the number of sigmas away from the mean. For other distributions, you need to compute the cdf of value in the parameter distribution and invert it using the ppf from the standard normal distribution.

set(value)

Set a new value for the parameter, ignoring the bounds.

soft_range(low, high, std)

Allow the parameter to vary within the given range, or with Gaussian probability, stray from the range.

valid()

Return true if the parameter is within the valid range.

value
class bumps.parameter.OperatorAdd(a, b)

Bases: bumps.parameter.BaseParameter

Parameter operator +

bounds

Fit bounds

dev(std, mean=0, limits=None, sigma=None, mu=None)

Allow the parameter to vary according to a normal distribution, with deviations from the mean added to the overall cost function for the model.

If mean is None, then it defaults to the current parameter value.

If limits are provide, then use a truncated normal distribution.

Note: sigma and mu have been replaced by std and mean, but are left in for backward compatibility.

discrete = False
dvalue
fittable = False
fixed = True
format()

Format the parameter, value and range as a string.

name = None
nllf()

Return -log(P) for the current parameter value.

parameters()
pdf(dist)

Allow the parameter to vary according to any continuous scipy.stats distribution.

pm(*args)

Allow the parameter to vary as value +/- delta.

pm(delta) -> [value-delta, value+delta]

pm(plus, minus) -> [value+minus, value+plus]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

pmp(*args)

Allow the parameter to vary as value +/- percent.

pmp(percent) -> [value*(1-percent/100), value*(1+percent/100)]

pmp(plus, minus) -> [value*(1+minus/100), value*(1+plus/100)]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

range(low, high)

Allow the parameter to vary within the given range.

residual()

Return the z score equivalent for the current parameter value.

That is, the given the value of the parameter in the underlying distribution, find the equivalent value in the standard normal. For a gaussian, this is the z score, in which you subtract the mean and divide by the standard deviation to get the number of sigmas away from the mean. For other distributions, you need to compute the cdf of value in the parameter distribution and invert it using the ppf from the standard normal distribution.

soft_range(low, high, std)

Allow the parameter to vary within the given range, or with Gaussian probability, stray from the range.

valid()

Return true if the parameter is within the valid range.

value
class bumps.parameter.OperatorDiv(a, b)

Bases: bumps.parameter.BaseParameter

Parameter operator /

bounds

Fit bounds

dev(std, mean=0, limits=None, sigma=None, mu=None)

Allow the parameter to vary according to a normal distribution, with deviations from the mean added to the overall cost function for the model.

If mean is None, then it defaults to the current parameter value.

If limits are provide, then use a truncated normal distribution.

Note: sigma and mu have been replaced by std and mean, but are left in for backward compatibility.

discrete = False
dvalue
fittable = False
fixed = True
format()

Format the parameter, value and range as a string.

name = None
nllf()

Return -log(P) for the current parameter value.

parameters()
pdf(dist)

Allow the parameter to vary according to any continuous scipy.stats distribution.

pm(*args)

Allow the parameter to vary as value +/- delta.

pm(delta) -> [value-delta, value+delta]

pm(plus, minus) -> [value+minus, value+plus]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

pmp(*args)

Allow the parameter to vary as value +/- percent.

pmp(percent) -> [value*(1-percent/100), value*(1+percent/100)]

pmp(plus, minus) -> [value*(1+minus/100), value*(1+plus/100)]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

range(low, high)

Allow the parameter to vary within the given range.

residual()

Return the z score equivalent for the current parameter value.

That is, the given the value of the parameter in the underlying distribution, find the equivalent value in the standard normal. For a gaussian, this is the z score, in which you subtract the mean and divide by the standard deviation to get the number of sigmas away from the mean. For other distributions, you need to compute the cdf of value in the parameter distribution and invert it using the ppf from the standard normal distribution.

soft_range(low, high, std)

Allow the parameter to vary within the given range, or with Gaussian probability, stray from the range.

valid()

Return true if the parameter is within the valid range.

value
class bumps.parameter.OperatorMul(a, b)

Bases: bumps.parameter.BaseParameter

Parameter operator *

bounds

Fit bounds

dev(std, mean=0, limits=None, sigma=None, mu=None)

Allow the parameter to vary according to a normal distribution, with deviations from the mean added to the overall cost function for the model.

If mean is None, then it defaults to the current parameter value.

If limits are provide, then use a truncated normal distribution.

Note: sigma and mu have been replaced by std and mean, but are left in for backward compatibility.

discrete = False
dvalue
fittable = False
fixed = True
format()

Format the parameter, value and range as a string.

name = None
nllf()

Return -log(P) for the current parameter value.

parameters()
pdf(dist)

Allow the parameter to vary according to any continuous scipy.stats distribution.

pm(*args)

Allow the parameter to vary as value +/- delta.

pm(delta) -> [value-delta, value+delta]

pm(plus, minus) -> [value+minus, value+plus]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

pmp(*args)

Allow the parameter to vary as value +/- percent.

pmp(percent) -> [value*(1-percent/100), value*(1+percent/100)]

pmp(plus, minus) -> [value*(1+minus/100), value*(1+plus/100)]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

range(low, high)

Allow the parameter to vary within the given range.

residual()

Return the z score equivalent for the current parameter value.

That is, the given the value of the parameter in the underlying distribution, find the equivalent value in the standard normal. For a gaussian, this is the z score, in which you subtract the mean and divide by the standard deviation to get the number of sigmas away from the mean. For other distributions, you need to compute the cdf of value in the parameter distribution and invert it using the ppf from the standard normal distribution.

soft_range(low, high, std)

Allow the parameter to vary within the given range, or with Gaussian probability, stray from the range.

valid()

Return true if the parameter is within the valid range.

value
class bumps.parameter.OperatorPow(a, b)

Bases: bumps.parameter.BaseParameter

Parameter operator **

bounds

Fit bounds

dev(std, mean=0, limits=None, sigma=None, mu=None)

Allow the parameter to vary according to a normal distribution, with deviations from the mean added to the overall cost function for the model.

If mean is None, then it defaults to the current parameter value.

If limits are provide, then use a truncated normal distribution.

Note: sigma and mu have been replaced by std and mean, but are left in for backward compatibility.

discrete = False
dvalue
fittable = False
fixed = True
format()

Format the parameter, value and range as a string.

name = None
nllf()

Return -log(P) for the current parameter value.

parameters()
pdf(dist)

Allow the parameter to vary according to any continuous scipy.stats distribution.

pm(*args)

Allow the parameter to vary as value +/- delta.

pm(delta) -> [value-delta, value+delta]

pm(plus, minus) -> [value+minus, value+plus]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

pmp(*args)

Allow the parameter to vary as value +/- percent.

pmp(percent) -> [value*(1-percent/100), value*(1+percent/100)]

pmp(plus, minus) -> [value*(1+minus/100), value*(1+plus/100)]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

range(low, high)

Allow the parameter to vary within the given range.

residual()

Return the z score equivalent for the current parameter value.

That is, the given the value of the parameter in the underlying distribution, find the equivalent value in the standard normal. For a gaussian, this is the z score, in which you subtract the mean and divide by the standard deviation to get the number of sigmas away from the mean. For other distributions, you need to compute the cdf of value in the parameter distribution and invert it using the ppf from the standard normal distribution.

soft_range(low, high, std)

Allow the parameter to vary within the given range, or with Gaussian probability, stray from the range.

valid()

Return true if the parameter is within the valid range.

value
class bumps.parameter.OperatorSub(a, b)

Bases: bumps.parameter.BaseParameter

Parameter operator -

bounds

Fit bounds

dev(std, mean=0, limits=None, sigma=None, mu=None)

Allow the parameter to vary according to a normal distribution, with deviations from the mean added to the overall cost function for the model.

If mean is None, then it defaults to the current parameter value.

If limits are provide, then use a truncated normal distribution.

Note: sigma and mu have been replaced by std and mean, but are left in for backward compatibility.

discrete = False
dvalue
fittable = False
fixed = True
format()

Format the parameter, value and range as a string.

name = None
nllf()

Return -log(P) for the current parameter value.

parameters()
pdf(dist)

Allow the parameter to vary according to any continuous scipy.stats distribution.

pm(*args)

Allow the parameter to vary as value +/- delta.

pm(delta) -> [value-delta, value+delta]

pm(plus, minus) -> [value+minus, value+plus]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

pmp(*args)

Allow the parameter to vary as value +/- percent.

pmp(percent) -> [value*(1-percent/100), value*(1+percent/100)]

pmp(plus, minus) -> [value*(1+minus/100), value*(1+plus/100)]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

range(low, high)

Allow the parameter to vary within the given range.

residual()

Return the z score equivalent for the current parameter value.

That is, the given the value of the parameter in the underlying distribution, find the equivalent value in the standard normal. For a gaussian, this is the z score, in which you subtract the mean and divide by the standard deviation to get the number of sigmas away from the mean. For other distributions, you need to compute the cdf of value in the parameter distribution and invert it using the ppf from the standard normal distribution.

soft_range(low, high, std)

Allow the parameter to vary within the given range, or with Gaussian probability, stray from the range.

valid()

Return true if the parameter is within the valid range.

value
class bumps.parameter.Parameter(value=None, bounds=None, fixed=None, name=None, **kw)[source]

Bases: bumps.parameter.BaseParameter

A parameter is a symbolic value.

It can be fixed or it can vary within bounds.

p = Parameter(3).pmp(10) # 3 +/- 10% p = Parameter(3).pmp(-5,10) # 3 in [2.85,3.3] rounded to 2 digits p = Parameter(3).pm(2) # 3 +/- 2 p = Parameter(3).pm(-1,2) # 3 in [2,5] p = Parameter(3).range(0,5) # 3 in [0,5]

It has hard limits on the possible values, and a range that should live within those hard limits. The value should lie within the range for it to be valid. Some algorithms may drive the value outside the range in order to satisfy soft It has a value which should lie within the range.

Other properties can decorate the parameter, such as tip for tool tip and units for units.

bounds

Fit bounds

clip_set(value)[source]

Set a new value for the parameter, clipping it to the bounds.

classmethod default(value, **kw)[source]

Create a new parameter with the value and kw attributes, or return the existing parameter if value is already a parameter.

The attributes are the same as those for Parameter, or whatever subclass cls of Parameter is being created.

dev(std, mean=0, limits=None, sigma=None, mu=None)

Allow the parameter to vary according to a normal distribution, with deviations from the mean added to the overall cost function for the model.

If mean is None, then it defaults to the current parameter value.

If limits are provide, then use a truncated normal distribution.

Note: sigma and mu have been replaced by std and mean, but are left in for backward compatibility.

discrete = False
feasible()[source]

Value is within the limits defined by the model

fittable = True
fixed = True
format()

Format the parameter, value and range as a string.

name = None
nllf()

Return -log(P) for the current parameter value.

parameters()
pdf(dist)

Allow the parameter to vary according to any continuous scipy.stats distribution.

pm(*args)

Allow the parameter to vary as value +/- delta.

pm(delta) -> [value-delta, value+delta]

pm(plus, minus) -> [value+minus, value+plus]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

pmp(*args)

Allow the parameter to vary as value +/- percent.

pmp(percent) -> [value*(1-percent/100), value*(1+percent/100)]

pmp(plus, minus) -> [value*(1+minus/100), value*(1+plus/100)]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

randomize(rng=None)[source]

Set a random value for the parameter.

range(low, high)

Allow the parameter to vary within the given range.

residual()

Return the z score equivalent for the current parameter value.

That is, the given the value of the parameter in the underlying distribution, find the equivalent value in the standard normal. For a gaussian, this is the z score, in which you subtract the mean and divide by the standard deviation to get the number of sigmas away from the mean. For other distributions, you need to compute the cdf of value in the parameter distribution and invert it using the ppf from the standard normal distribution.

set(value)[source]

Set a new value for the parameter, ignoring the bounds.

soft_range(low, high, std)

Allow the parameter to vary within the given range, or with Gaussian probability, stray from the range.

valid()

Return true if the parameter is within the valid range.

class bumps.parameter.ParameterSet(reference, names=None)[source]

Bases: object

A parameter that depends on the model.

pm(*args, **kw)[source]

Like parameter.Parameter.pm(), but applied to all models.

pmp(*args, **kw)[source]

Like parameter.Parameter.pmp(), but applied to all models.

range(*args, **kw)[source]

Like parameter.Parameter.range(), but applied to all models.

set_model(index)[source]

Set the underlying model parameter to the value of the nth model.

values
class bumps.parameter.Reference(obj, attr, **kw)[source]

Bases: bumps.parameter.Parameter

Create an adaptor so that a model attribute can be treated as if it were a parameter. This allows only direct access, wherein the storage for the parameter value is provided by the underlying model.

Indirect access, wherein the storage is provided by the parameter, cannot be supported since the parameter has no way to detect that the model is asking for the value of the attribute. This means that model attributes cannot be assigned to parameter expressions without some trigger to update the values of the attributes in the model.

bounds

Fit bounds

clip_set(value)

Set a new value for the parameter, clipping it to the bounds.

default(value, **kw)

Create a new parameter with the value and kw attributes, or return the existing parameter if value is already a parameter.

The attributes are the same as those for Parameter, or whatever subclass cls of Parameter is being created.

dev(std, mean=0, limits=None, sigma=None, mu=None)

Allow the parameter to vary according to a normal distribution, with deviations from the mean added to the overall cost function for the model.

If mean is None, then it defaults to the current parameter value.

If limits are provide, then use a truncated normal distribution.

Note: sigma and mu have been replaced by std and mean, but are left in for backward compatibility.

discrete = False
feasible()

Value is within the limits defined by the model

fittable = True
fixed = True
format()

Format the parameter, value and range as a string.

name = None
nllf()

Return -log(P) for the current parameter value.

parameters()
pdf(dist)

Allow the parameter to vary according to any continuous scipy.stats distribution.

pm(*args)

Allow the parameter to vary as value +/- delta.

pm(delta) -> [value-delta, value+delta]

pm(plus, minus) -> [value+minus, value+plus]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

pmp(*args)

Allow the parameter to vary as value +/- percent.

pmp(percent) -> [value*(1-percent/100), value*(1+percent/100)]

pmp(plus, minus) -> [value*(1+minus/100), value*(1+plus/100)]

In the plus/minus form, one of the numbers should be plus and the other minus, but it doesn’t matter which.

The resulting range is converted to “nice” numbers.

randomize(rng=None)

Set a random value for the parameter.

range(low, high)

Allow the parameter to vary within the given range.

residual()

Return the z score equivalent for the current parameter value.

That is, the given the value of the parameter in the underlying distribution, find the equivalent value in the standard normal. For a gaussian, this is the z score, in which you subtract the mean and divide by the standard deviation to get the number of sigmas away from the mean. For other distributions, you need to compute the cdf of value in the parameter distribution and invert it using the ppf from the standard normal distribution.

set(value)

Set a new value for the parameter, ignoring the bounds.

soft_range(low, high, std)

Allow the parameter to vary within the given range, or with Gaussian probability, stray from the range.

valid()

Return true if the parameter is within the valid range.

value
bumps.parameter.current(s)[source]
bumps.parameter.fittable(s)[source]

Return the list of fittable parameters in no paraticular order.

Note that some fittable parameters may be fixed during the fit.

bumps.parameter.flatten(s)[source]
bumps.parameter.format(p, indent=0)[source]

Format parameter set for printing.

Note that this only says how the parameters are arranged, not how they relate to each other.

bumps.parameter.function(op)[source]

Convert a function into a delayed evaluator.

The value of the function is computed from the values of the parameters at the time that the function value is requested rather than when the function is created.

bumps.parameter.randomize(s)[source]

Set random values to the parameters in the parameter set, with values chosen according to the bounds.

bumps.parameter.substitute(a)[source]

Return structure a with values substituted for all parameters.

The function traverses lists, tuples and dicts recursively. Things which are not parameters are returned directly.

bumps.parameter.summarize(pars, sorted=False)[source]

Return a stylized list of parameter names and values with range bars suitable for printing.

If sorted, then print the parameters sorted alphabetically by name.

bumps.parameter.unique(s)[source]

Return the unique set of parameters

The ordering is stable. The same parameters/dependencies will always return the same ordering, with the first occurrence first.

bumps.parameter.varying(s)[source]

Return the list of fitted parameters in the model.

This is the set of parameters that will vary during the fit.