parameter - Optimization parameter definition

Alias

Parameter alias.

BaseParameter

Root of the parameter class, defining arithmetic on parameters

Constant

An unmodifiable value.

Constraint

FreeVariables

A collection of parameter sets for a group of models.

Function

Delayed function evaluator.

IntegerParameter

Operator

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.

acosd

Return the arc cosine (measured in in degrees) of x.

arccosd

Return the arc cosine (measured in in degrees) of x.

arcsind

Return the arc sine (measured in in degrees) of x.

arctan2d

Return the arc tangent (measured in in degrees) of y/x.

arctand

Return the arc tangent (measured in in degrees) of x.

asind

Return the arc sine (measured in in degrees) of x.

atan2d

Return the arc tangent (measured in in degrees) of y/x.

atand

Return the arc tangent (measured in in degrees) of x.

boxed_function

cosd

Return the cosine of x (measured in in degrees).

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.

sind

Return the sine of x (measured in in degrees).

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.

tand

Return the tangent of x (measured in in degrees).

test_operator

to_dict

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.

Deprecated Reference does this better.

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

Bases: object

Root of the parameter class, defining arithmetic on parameters

arccos(**kw)

Return the arc cosine (measured in radians) of x.

The result is between 0 and pi.

arccosh(**kw)

Return the inverse hyperbolic cosine of x.

arcsin(**kw)

Return the arc sine (measured in radians) of x.

The result is between -pi/2 and pi/2.

arcsinh(**kw)

Return the inverse hyperbolic sine of x.

arctan(**kw)

Return the arc tangent (measured in radians) of x.

The result is between -pi/2 and pi/2.

arctanh(**kw)

Return the inverse hyperbolic tangent of x.

property bounds

Fit bounds

ceil(**kw)

Return the ceiling of x as an Integral.

This is the smallest integer >= x.

cos(**kw)

Return the cosine of x (measured in radians).

cosh(**kw)

Return the hyperbolic cosine of x.

degrees(**kw)

Convert angle x from radians to degrees.

dev(std, mean=None, 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
exp(**kw)

Return e raised to the power of x.

expm1(**kw)

Return exp(x)-1.

This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.

fittable = False
fixed = True
floor(**kw)

Return the floor of x as an Integral.

This is the largest integer <= x.

format()[source]

Format the parameter, value and range as a string.

log(x[, base=math.e])

Return the logarithm of x to the given base.

If the base not specified, returns the natural logarithm (base e) of x.

log10(**kw)

Return the base 10 logarithm of x.

log1p(**kw)

Return the natural logarithm of 1+x (base e).

The result is computed in a way which is accurate for x near zero.

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(plus, minus=None, limits=None)[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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

pmp(plus, minus=None, limits=None)[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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

radians(**kw)

Convert angle x from degrees to radians.

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.

sin(**kw)

Return the sine of x (measured in radians).

sinh(**kw)

Return the hyperbolic sine of x.

soft_range(low, high, std)[source]

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

sqrt(**kw)

Return the square root of x.

tan(**kw)

Return the tangent of x (measured in radians).

tanh(**kw)

Return the hyperbolic tangent of x.

to_dict()[source]

Return a dict represention of the object.

trunc(**kw)

Truncates the Real x to the nearest Integral toward 0.

Uses the __trunc__ magic method.

valid()[source]

Return true if the parameter is within the valid range.

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

Bases: BaseParameter

An unmodifiable value.

arccos(**kw)

Return the arc cosine (measured in radians) of x.

The result is between 0 and pi.

arccosh(**kw)

Return the inverse hyperbolic cosine of x.

arcsin(**kw)

Return the arc sine (measured in radians) of x.

The result is between -pi/2 and pi/2.

arcsinh(**kw)

Return the inverse hyperbolic sine of x.

arctan(**kw)

Return the arc tangent (measured in radians) of x.

The result is between -pi/2 and pi/2.

arctanh(**kw)

Return the inverse hyperbolic tangent of x.

property bounds

Fit bounds

ceil(**kw)

Return the ceiling of x as an Integral.

This is the smallest integer >= x.

cos(**kw)

Return the cosine of x (measured in radians).

cosh(**kw)

Return the hyperbolic cosine of x.

degrees(**kw)

Convert angle x from radians to degrees.

dev(std, mean=None, 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
exp(**kw)

Return e raised to the power of x.

expm1(**kw)

Return exp(x)-1.

This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.

fittable = False
fixed = True
floor(**kw)

Return the floor of x as an Integral.

This is the largest integer <= x.

format()

Format the parameter, value and range as a string.

log(x[, base=math.e])

Return the logarithm of x to the given base.

If the base not specified, returns the natural logarithm (base e) of x.

log10(**kw)

Return the base 10 logarithm of x.

log1p(**kw)

Return the natural logarithm of 1+x (base e).

The result is computed in a way which is accurate for x near zero.

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(plus, minus=None, limits=None)

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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

pmp(plus, minus=None, limits=None)

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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

radians(**kw)

Convert angle x from degrees to radians.

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.

sin(**kw)

Return the sine of x (measured in radians).

sinh(**kw)

Return the hyperbolic sine of x.

soft_range(low, high, std)

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

sqrt(**kw)

Return the square root of x.

tan(**kw)

Return the tangent of x (measured in radians).

tanh(**kw)

Return the hyperbolic tangent of x.

to_dict()

Return a dict represention of the object.

trunc(**kw)

Truncates the Real x to the nearest Integral toward 0.

Uses the __trunc__ magic method.

valid()

Return true if the parameter is within the valid range.

property value
class bumps.parameter.Constraint(a, b, op_name, op_str='')[source]

Bases: object

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.

get_model(i)[source]

Get the parameters for model i as {reference: substitution}

parameters()[source]

Return the set of free variables for all the models.

set_model(i)[source]

Set the reference parameters for model i.

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

Bases: 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.

arccos(**kw)

Return the arc cosine (measured in radians) of x.

The result is between 0 and pi.

arccosh(**kw)

Return the inverse hyperbolic cosine of x.

arcsin(**kw)

Return the arc sine (measured in radians) of x.

The result is between -pi/2 and pi/2.

arcsinh(**kw)

Return the inverse hyperbolic sine of x.

arctan(**kw)

Return the arc tangent (measured in radians) of x.

The result is between -pi/2 and pi/2.

arctanh(**kw)

Return the inverse hyperbolic tangent of x.

args
property bounds

Fit bounds

ceil(**kw)

Return the ceiling of x as an Integral.

This is the smallest integer >= x.

cos(**kw)

Return the cosine of x (measured in radians).

cosh(**kw)

Return the hyperbolic cosine of x.

degrees(**kw)

Convert angle x from radians to degrees.

dev(std, mean=None, 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
exp(**kw)

Return e raised to the power of x.

expm1(**kw)

Return exp(x)-1.

This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.

fittable = False
fixed = True
floor(**kw)

Return the floor of x as an Integral.

This is the largest integer <= x.

format()

Format the parameter, value and range as a string.

kw
log(x[, base=math.e])

Return the logarithm of x to the given base.

If the base not specified, returns the natural logarithm (base e) of x.

log10(**kw)

Return the base 10 logarithm of x.

log1p(**kw)

Return the natural logarithm of 1+x (base e).

The result is computed in a way which is accurate for x near zero.

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(plus, minus=None, limits=None)

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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

pmp(plus, minus=None, limits=None)

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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

radians(**kw)

Convert angle x from degrees to radians.

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.

sin(**kw)

Return the sine of x (measured in radians).

sinh(**kw)

Return the hyperbolic sine of x.

soft_range(low, high, std)

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

sqrt(**kw)

Return the square root of x.

tan(**kw)

Return the tangent of x (measured in radians).

tanh(**kw)

Return the hyperbolic tangent of x.

to_dict()[source]

Return a dict represention of the object.

trunc(**kw)

Truncates the Real x to the nearest Integral toward 0.

Uses the __trunc__ magic method.

valid()

Return true if the parameter is within the valid range.

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

Bases: Parameter

arccos(**kw)

Return the arc cosine (measured in radians) of x.

The result is between 0 and pi.

arccosh(**kw)

Return the inverse hyperbolic cosine of x.

arcsin(**kw)

Return the arc sine (measured in radians) of x.

The result is between -pi/2 and pi/2.

arcsinh(**kw)

Return the inverse hyperbolic sine of x.

arctan(**kw)

Return the arc tangent (measured in radians) of x.

The result is between -pi/2 and pi/2.

arctanh(**kw)

Return the inverse hyperbolic tangent of x.

property bounds

Fit bounds

ceil(**kw)

Return the ceiling of x as an Integral.

This is the smallest integer >= x.

clip_set(value)

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

cos(**kw)

Return the cosine of x (measured in radians).

cosh(**kw)

Return the hyperbolic cosine of x.

classmethod 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.

degrees(**kw)

Convert angle x from radians to degrees.

dev(std, mean=None, 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
exp(**kw)

Return e raised to the power of x.

expm1(**kw)

Return exp(x)-1.

This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.

feasible()

Value is within the limits defined by the model

fittable = True
fixed = True
floor(**kw)

Return the floor of x as an Integral.

This is the largest integer <= x.

format()

Format the parameter, value and range as a string.

log(x[, base=math.e])

Return the logarithm of x to the given base.

If the base not specified, returns the natural logarithm (base e) of x.

log10(**kw)

Return the base 10 logarithm of x.

log1p(**kw)

Return the natural logarithm of 1+x (base e).

The result is computed in a way which is accurate for x near zero.

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(plus, minus=None, limits=None)

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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

pmp(plus, minus=None, limits=None)

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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

radians(**kw)

Convert angle x from degrees to radians.

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.

sin(**kw)

Return the sine of x (measured in radians).

sinh(**kw)

Return the hyperbolic sine of x.

soft_range(low, high, std)

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

sqrt(**kw)

Return the square root of x.

tan(**kw)

Return the tangent of x (measured in radians).

tanh(**kw)

Return the hyperbolic tangent of x.

to_dict()

Return a dict represention of the object.

trunc(**kw)

Truncates the Real x to the nearest Integral toward 0.

Uses the __trunc__ magic method.

valid()

Return true if the parameter is within the valid range.

property value
class bumps.parameter.Operator(a, b, op_name, op_str)[source]

Bases: BaseParameter

Parameter operator

arccos(**kw)

Return the arc cosine (measured in radians) of x.

The result is between 0 and pi.

arccosh(**kw)

Return the inverse hyperbolic cosine of x.

arcsin(**kw)

Return the arc sine (measured in radians) of x.

The result is between -pi/2 and pi/2.

arcsinh(**kw)

Return the inverse hyperbolic sine of x.

arctan(**kw)

Return the arc tangent (measured in radians) of x.

The result is between -pi/2 and pi/2.

arctanh(**kw)

Return the inverse hyperbolic tangent of x.

property bounds

Fit bounds

ceil(**kw)

Return the ceiling of x as an Integral.

This is the smallest integer >= x.

cos(**kw)

Return the cosine of x (measured in radians).

cosh(**kw)

Return the hyperbolic cosine of x.

degrees(**kw)

Convert angle x from radians to degrees.

dev(std, mean=None, 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
property dvalue
exp(**kw)

Return e raised to the power of x.

expm1(**kw)

Return exp(x)-1.

This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.

fittable = False
fixed = True
floor(**kw)

Return the floor of x as an Integral.

This is the largest integer <= x.

format()

Format the parameter, value and range as a string.

log(x[, base=math.e])

Return the logarithm of x to the given base.

If the base not specified, returns the natural logarithm (base e) of x.

log10(**kw)

Return the base 10 logarithm of x.

log1p(**kw)

Return the natural logarithm of 1+x (base e).

The result is computed in a way which is accurate for x near zero.

name = None
nllf()

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

parameters()[source]
pdf(dist)

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

pm(plus, minus=None, limits=None)

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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

pmp(plus, minus=None, limits=None)

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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

radians(**kw)

Convert angle x from degrees to radians.

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.

sin(**kw)

Return the sine of x (measured in radians).

sinh(**kw)

Return the hyperbolic sine of x.

soft_range(low, high, std)

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

sqrt(**kw)

Return the square root of x.

tan(**kw)

Return the tangent of x (measured in radians).

tanh(**kw)

Return the hyperbolic tangent of x.

to_dict()[source]

Return a dict represention of the object.

trunc(**kw)

Truncates the Real x to the nearest Integral toward 0.

Uses the __trunc__ magic method.

valid()

Return true if the parameter is within the valid range.

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

Bases: 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.

arccos(**kw)

Return the arc cosine (measured in radians) of x.

The result is between 0 and pi.

arccosh(**kw)

Return the inverse hyperbolic cosine of x.

arcsin(**kw)

Return the arc sine (measured in radians) of x.

The result is between -pi/2 and pi/2.

arcsinh(**kw)

Return the inverse hyperbolic sine of x.

arctan(**kw)

Return the arc tangent (measured in radians) of x.

The result is between -pi/2 and pi/2.

arctanh(**kw)

Return the inverse hyperbolic tangent of x.

property bounds

Fit bounds

ceil(**kw)

Return the ceiling of x as an Integral.

This is the smallest integer >= x.

clip_set(value)[source]

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

cos(**kw)

Return the cosine of x (measured in radians).

cosh(**kw)

Return the hyperbolic cosine of x.

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.

degrees(**kw)

Convert angle x from radians to degrees.

dev(std, mean=None, 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
exp(**kw)

Return e raised to the power of x.

expm1(**kw)

Return exp(x)-1.

This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.

feasible()[source]

Value is within the limits defined by the model

fittable = True
fixed = True
floor(**kw)

Return the floor of x as an Integral.

This is the largest integer <= x.

format()

Format the parameter, value and range as a string.

log(x[, base=math.e])

Return the logarithm of x to the given base.

If the base not specified, returns the natural logarithm (base e) of x.

log10(**kw)

Return the base 10 logarithm of x.

log1p(**kw)

Return the natural logarithm of 1+x (base e).

The result is computed in a way which is accurate for x near zero.

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(plus, minus=None, limits=None)

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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

pmp(plus, minus=None, limits=None)

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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

radians(**kw)

Convert angle x from degrees to radians.

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.

sin(**kw)

Return the sine of x (measured in radians).

sinh(**kw)

Return the hyperbolic sine of x.

soft_range(low, high, std)

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

sqrt(**kw)

Return the square root of x.

tan(**kw)

Return the tangent of x (measured in radians).

tanh(**kw)

Return the hyperbolic tangent of x.

to_dict()

Return a dict represention of the object.

trunc(**kw)

Truncates the Real x to the nearest Integral toward 0.

Uses the __trunc__ magic method.

valid()

Return true if the parameter is within the valid range.

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

Bases: object

A parameter that depends on the model.

get_model(index)[source]

Get the reference and underlying model parameter for the nth model.

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

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

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

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

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

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

set_model(index)[source]

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

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

Bases: 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.

arccos(**kw)

Return the arc cosine (measured in radians) of x.

The result is between 0 and pi.

arccosh(**kw)

Return the inverse hyperbolic cosine of x.

arcsin(**kw)

Return the arc sine (measured in radians) of x.

The result is between -pi/2 and pi/2.

arcsinh(**kw)

Return the inverse hyperbolic sine of x.

arctan(**kw)

Return the arc tangent (measured in radians) of x.

The result is between -pi/2 and pi/2.

arctanh(**kw)

Return the inverse hyperbolic tangent of x.

property bounds

Fit bounds

ceil(**kw)

Return the ceiling of x as an Integral.

This is the smallest integer >= x.

clip_set(value)

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

cos(**kw)

Return the cosine of x (measured in radians).

cosh(**kw)

Return the hyperbolic cosine of x.

classmethod 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.

degrees(**kw)

Convert angle x from radians to degrees.

dev(std, mean=None, 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
exp(**kw)

Return e raised to the power of x.

expm1(**kw)

Return exp(x)-1.

This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.

feasible()

Value is within the limits defined by the model

fittable = True
fixed = True
floor(**kw)

Return the floor of x as an Integral.

This is the largest integer <= x.

format()

Format the parameter, value and range as a string.

log(x[, base=math.e])

Return the logarithm of x to the given base.

If the base not specified, returns the natural logarithm (base e) of x.

log10(**kw)

Return the base 10 logarithm of x.

log1p(**kw)

Return the natural logarithm of 1+x (base e).

The result is computed in a way which is accurate for x near zero.

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(plus, minus=None, limits=None)

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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

pmp(plus, minus=None, limits=None)

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.

If limits are provided, bound the end points of the range to lie within the limits.

The resulting range is converted to “nice” numbers.

radians(**kw)

Convert angle x from degrees to radians.

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.

sin(**kw)

Return the sine of x (measured in radians).

sinh(**kw)

Return the hyperbolic sine of x.

soft_range(low, high, std)

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

sqrt(**kw)

Return the square root of x.

tan(**kw)

Return the tangent of x (measured in radians).

tanh(**kw)

Return the hyperbolic tangent of x.

to_dict()[source]

Return a dict represention of the object.

trunc(**kw)

Truncates the Real x to the nearest Integral toward 0.

Uses the __trunc__ magic method.

valid()

Return true if the parameter is within the valid range.

property value
bumps.parameter.acosd(v)[source]

Return the arc cosine (measured in in degrees) of x.

bumps.parameter.arccosd(v)

Return the arc cosine (measured in in degrees) of x.

bumps.parameter.arcsind(v)

Return the arc sine (measured in in degrees) of x.

bumps.parameter.arctan2d(dy, dx)

Return the arc tangent (measured in in degrees) of y/x. Unlike atan(y/x), the signs of both x and y are considered.

bumps.parameter.arctand(v)

Return the arc tangent (measured in in degrees) of x.

bumps.parameter.asind(v)[source]

Return the arc sine (measured in in degrees) of x.

bumps.parameter.atan2d(dy, dx)[source]

Return the arc tangent (measured in in degrees) of y/x. Unlike atan(y/x), the signs of both x and y are considered.

bumps.parameter.atand(v)[source]

Return the arc tangent (measured in in degrees) of x.

bumps.parameter.boxed_function(f)[source]
bumps.parameter.cosd(v)[source]

Return the cosine of x (measured in in degrees).

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, freevars={}, field=None)[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.sind(v)[source]

Return the sine of x (measured in in degrees).

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.tand(v)[source]

Return the tangent of x (measured in in degrees).

bumps.parameter.test_operator()[source]
bumps.parameter.to_dict(p)[source]
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.