# Bumps documentation

## parameter - Optimization parameter definition

`Alias` | Parameter alias.
`Calculation` | A Parameter with a model-specific, calculated value.
`Comparisons` | comparison operators
`Constant` | Saved state for an unmodifiable value.
`Constraint` | Express inequality constraints between model elements
`Expression` | Parameter expression
`FreeVariables` | A collection of parameter sets for a group of models.
`Function` | DEPRECATED
`Normal` | Normal distribution (Gaussian)
`OperatorMixin` | The set of operations that can be performed on parameter-like objects Parameter, Constant, Expression.
`Operators` | Operators that can be used to construct Expressions
`Parameter` | A parameter is a container for 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.
`SupportsPrior` |
`Uniform` | Uniform distribution with hard boundaries
`UniformSoftBounded` | Uniform distribution with error-function PDF on boundaries
`UserFunction` | User-defined functions.
`ValueProtocol` | Values can be combined to form expressions Provide a suite of operators for creating parameter expressions.
`Variable` | Saved state for a random variable in the model.
`acos` |
`acosd` | Return the arc cosine (measured in in degrees) of x.
`acosh` |
`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.
`asin` |
`asind` | Return the arc sine (measured in in degrees) of x.
`asinh` |
`atan` |
`atan2` |
`atan2d` | Return the arc tangent (measured in in degrees) of y/x.
`atand` | Return the arc tangent (measured in in degrees) of x.
`atanh` |
`copy_linked` | make a copy of an object with parameters
`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.
`max` | max(Parameter)
`min` | min(Parameter)
`priors` | Return the list of parameters (fitted or computed) that have prior probabilities associated with them.
`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.
`tag_all` |
`tand` | Return the tangent of x (measured in in degrees).
`test_operator` |
`to_dict` |
`unique` | Return the unique set of parameters
`untag_all` |
`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)

  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.

  parameters()
  to_dict()
  update()

class bumps.parameter.Calculation(description: str = '', function: Callable = None)

  Bases: `ValueProtocol`

  A Parameter with a model-specific, calculated value. The function used to calculate this value should be well-documented in the description field, e.g. Stack.thickness: description = “a sum of the thicknesses of all layers in the stack”

  arccos()
  arccosh()
  arcsin()
  arcsinh()
  arctan()
  arctan2()
  arctanh()
  ceil()
  cos()
  cosh()
  degrees()
  description: str
  exp()
  expm1()
  fittable: bool = False
  fixed: bool = True
  floor()
  log()
  log10()
  log1p()
  max()
  min()
  parameters() → List[Parameter]
  radians()
  rint()
  round()
  set_function(function)
  sin()
  sinh()
  sqrt()
  tan()
  tanh()
  trunc()
  property value

class bumps.parameter.Comparisons(*values)

  Bases: `Enum`

  comparison operators

  ge = '>='
  gt = '>'
  le = '<='
  lt = '<'

class bumps.parameter.Constant(value: float, name: str | None = None, id: str = <factory>)

  Bases: `ValueProtocol`

  Saved state for an unmodifiable value.

  A constant is like a fixed parameter. You can’t change it’s value, set it equal to another parameter, or assign a prior distribution.

  arccos()
  arccosh()
  arcsin()
  arcsinh()
  arctan()
  arctan2()
  arctanh()
  ceil()
  cos()
  cosh()
  degrees()
  exp()
  expm1()
  fittable: bool = False
  fixed: bool = True
  floor()
  id: str
  log()
  log10()
  log1p()
  max()
  min()
  name: str | None = None
  parameters()
  radians()
  rint()
  round()
  sin()
  sinh()
  sqrt()
  tan()
  tanh()
  trunc()
  value: float

class bumps.parameter.Constraint(a, b, op)

  Bases: `object`

  Express inequality constraints between model elements

  a: Parameter | Expression | Calculation | float
  b: Parameter | Expression | Calculation | float
  fixed = True
  op: Comparisons
  property satisfied

class bumps.parameter.Expression(op: str | Operators | UserFunction, args)

  Bases: `ValueProtocol`

  Parameter expression

  arccos()
  arccosh()
  arcsin()
  arcsinh()
  arctan()
  arctan2()
  arctanh()
  args: Sequence[Expression | Parameter | Calculation | float]
  ceil()
  cos()
  cosh()
  degrees()
  exp()
  expm1()
  fittable: bool = False
  fixed: bool = True
  floor()
  log()
  log10()
  log1p()
  max()
  min()
  property name
  op: Operators | UserFunction
  parameters()
  radians()
  rint()
  round()
  sin()
  sinh()
  sqrt()
  tan()
  tanh()
  trunc()
  property value

class bumps.parameter.FreeVariables(names=None, parametersets=None, **kw)

  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)

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

  names: List[str]
  parameters()

    Return the set of free variables for all the models.

  parametersets: Dict[str, ParameterSet]
  set_model(i)

    Set the reference parameters for model i.

  to_dict()

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

  Bases: `ValueProtocol`

  DEPRECATED

  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()
  arccosh()
  arcsin()
  arcsinh()
  arctan()
  arctan2()
  arctanh()
  args: Any | None
  ceil()
  cos()
  cosh()
  degrees()
  exp()
  expm1()
  fittable: bool = False
  fixed: bool = True
  floor()
  kw: Dict[Any, Any]
  log()
  log10()
  log1p()
  max()
  min()
  op: Callable[[...], float]
  parameters()
  radians()
  rint()
  round()
  sin()
  sinh()
  sqrt()
  tan()
  tanh()
  to_dict()
  trunc()
  property value

class bumps.parameter.Normal(std: float, mean: float)

  Bases: `object`

  Normal distribution (Gaussian)

  mean: float
  std: float

class bumps.parameter.OperatorMixin

  Bases: `object`

  The set of operations that can be performed on parameter-like objects Parameter, Constant, Expression.

  These include: +, -, , /, //, *, abs, float, int

  Also, numpy math functions: sin, cos, tan, …

  Much like abs(obj) => obj.__abs__(), np.sin(obj) => obj.sin()

  arccos()
  arccosh()
  arcsin()
  arcsinh()
  arctan()
  arctan2()
  arctanh()
  ceil()
  cos()
  cosh()
  degrees()
  exp()
  expm1()
  floor()
  log()
  log10()
  log1p()
  max()
  min()
  radians()
  rint()
  round()
  sin()
  sinh()
  sqrt()
  tan()
  tanh()
  trunc()
  value: float

class bumps.parameter.Operators(*values)

  Bases: `str`, `Enum`

  Operators that can be used to construct Expressions

  abs = 'abs'
  add = 'add'
  arccos = 'arccos'
  arccosh = 'arccosh'
  arcsin = 'arcsin'
  arcsinh = 'arcsinh'
  arctan = 'arctan'
  arctan2 = 'arctan2'
  arctanh = 'arctanh'
  capitalize()

    Return a capitalized version of the string.

    More specifically, make the first character have upper case and the rest lower case.

  casefold()

    Return a version of the string suitable for caseless comparisons.

  ceil = 'ceil'
  center(width, fillchar=' ', /)

    Return a centered string of length width.

    Padding is done using the specified fill character (default is a space).

  cos = 'cos'
  cosh = 'cosh'
  count()

    Return the number of non-overlapping occurrences of substring sub in string S[start:end].

    Optional arguments start and end are interpreted as in slice notation.

  degrees = 'degrees'
  encode(encoding='utf-8', errors='strict')

    Encode the string using the codec registered for encoding.

    encoding

      The encoding in which to encode the string.

    errors

      The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

  endswith()

    Return True if the string ends with the specified suffix, False otherwise.

    suffix

      A string or a tuple of strings to try.

    start

      Optional start position. Default: start of the string.

    end

      Optional stop position. Default: end of the string.

  exp = 'exp'
  expandtabs(tabsize=8)

    Return a copy where all tab characters are expanded using spaces.

    If tabsize is not given, a tab size of 8 characters is assumed.

  expm1 = 'expm1'
  find()

    Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].

    Optional arguments start and end are interpreted as in slice notation. Return -1 on failure.

  floor = 'floor'
  floordiv = 'floordiv'
  format(*args, **kwargs)

    Return a formatted version of the string, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

  format_map(mapping, /)

    Return a formatted version of the string, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

  index()

    Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].

    Optional arguments start and end are interpreted as in slice notation. Raises ValueError when the substring is not found.

  isalnum()

    Return True if the string is an alpha-numeric string, False otherwise.

    A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

  isalpha()

    Return True if the string is an alphabetic string, False otherwise.

    A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

  isascii()

    Return True if all characters in the string are ASCII, False otherwise.

    ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

  isdecimal()

    Return True if the string is a decimal string, False otherwise.

    A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

  isdigit()

    Return True if the string is a digit string, False otherwise.

    A string is a digit string if all characters in the string are digits and there is at least one character in the string.

  isidentifier()

    Return True if the string is a valid Python identifier, False otherwise.

    Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

  islower()

    Return True if the string is a lowercase string, False otherwise.

    A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

  isnumeric()

    Return True if the string is a numeric string, False otherwise.

    A string is numeric if all characters in the string are numeric and there is at least one character in the string.

  isprintable()

    Return True if all characters in the string are printable, False otherwise.

    A character is printable if repr() may use it in its output.

  isspace()

    Return True if the string is a whitespace string, False otherwise.

    A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

  istitle()

    Return True if the string is a title-cased string, False otherwise.

    In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

  isupper()

    Return True if the string is an uppercase string, False otherwise.

    A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

  join(iterable, /)

    Concatenate any number of strings.

    The string whose method is called is inserted in between each given string. The result is returned as a new string.

    Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

  ljust(width, fillchar=' ', /)

    Return a left-justified string of length width.

    Padding is done using the specified fill character (default is a space).

  log = 'log'
  log10 = 'log10'
  log1p = 'log1p'
  lower()

    Return a copy of the string converted to lowercase.

  lstrip(chars=None, /)

    Return a copy of the string with leading whitespace removed.

    If chars is given and not None, remove characters in chars instead.

  static maketrans()

    Return a translation table usable for str.translate().

    If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

  max = 'max'
  min = 'min'
  mul = 'mul'
  neg = 'neg'
  partition(sep, /)

    Partition the string into three parts using the given separator.

    This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

    If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

  pos = 'pos'
  pow = 'pow'
  radians = 'radians'
  removeprefix(prefix, /)

    Return a str with the given prefix string removed if present.

    If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

  removesuffix(suffix, /)

    Return a str with the given suffix string removed if present.

    If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

  replace(old, new, /, count=-1)

    Return a copy with all occurrences of substring old replaced by new.

    > count

    >   Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

    If the optional argument count is given, only the first count occurrences are replaced.

  rfind()

    Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].

    Optional arguments start and end are interpreted as in slice notation. Return -1 on failure.

  rindex()

    Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].

    Optional arguments start and end are interpreted as in slice notation. Raises ValueError when the substring is not found.

  rint = 'rint'
  rjust(width, fillchar=' ', /)

    Return a right-justified string of length width.

    Padding is done using the specified fill character (default is a space).

  round = 'round'
  rpartition(sep, /)

    Partition the string into three parts using the given separator.

    This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

    If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

  rsplit(sep=None, maxsplit=-1)

    Return a list of the substrings in the string, using sep as the separator string.

    > sep

    >   The separator used to split the string.

    >   When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

    > maxsplit

    >   Maximum number of splits. -1 (the default value) means no limit.

    Splitting starts at the end of the string and works to the front.

  rstrip(chars=None, /)

    Return a copy of the string with trailing whitespace removed.

    If chars is given and not None, remove characters in chars instead.

  sin = 'sin'
  sinh = 'sinh'
  split(sep=None, maxsplit=-1)

    Return a list of the substrings in the string, using sep as the separator string.

    > sep

    >   The separator used to split the string.

    >   When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

    > maxsplit

    >   Maximum number of splits. -1 (the default value) means no limit.

    Splitting starts at the front of the string and works to the end.

    Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

  splitlines(keepends=False)

    Return a list of the lines in the string, breaking at line boundaries.

    Line breaks are not included in the resulting list unless keepends is given and true.

  sqrt = 'sqrt'
  startswith()

    Return True if the string starts with the specified prefix, False otherwise.

    prefix

      A string or a tuple of strings to try.

    start

      Optional start position. Default: start of the string.

    end

      Optional stop position. Default: end of the string.

  strip(chars=None, /)

    Return a copy of the string with leading and trailing whitespace removed.

    If chars is given and not None, remove characters in chars instead.

  sub = 'sub'
  swapcase()

    Convert uppercase characters to lowercase and lowercase characters to uppercase.

  tan = 'tan'
  tanh = 'tanh'
  title()

    Return a version of the string where each word is titlecased.

    More specifically, words start with uppercased characters and all remaining cased characters have lower case.

  translate(table, /)

    Replace each character in the string using the given translation table.

    > table

    >   Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

    The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

  truediv = 'truediv'
  trunc = 'trunc'
  upper()

    Return a copy of the string converted to uppercase.

  zfill(width, /)

    Pad a numeric string with zeros on the left, to fill a field of the given width.

    The string is never truncated.

class bumps.parameter.Parameter(value: float | Tuple[float, float] | None = None, slot: Variable | Expression | Parameter | Calculation | float | None = None, fixed: bool | None = None, name: str | None = None, id: str | None = None, limits: Tuple[float | Literal[None, '-inf'], float | Literal[None, 'inf']] | None = None, bounds: Tuple[float | Literal['-inf'], float | Literal['inf']] | None = None, distribution: Uniform | Normal = Uniform(), discrete: bool = False, tags: List[str] | None = None, **kw)

  Bases: `ValueProtocol`, `SupportsPrior`

  A parameter is a container for a symbolic value.

  Parameters have a prior probability, as set by a bounds constraint:

  > import numpy as np from scipy.stats.distributions import lognorm from bumps.parameter import Parameter

  > p = Parameter(3) p.pmp(10) # 3 +/- 10% uniform p.pmp(-5,10) # 3 in [2.85, 3.30] uniform p.pm(2) # 3 +/- 2 uniform p.pm(-1,2) # 3 in [2,5] uniform p.range(0,5) # 3 in [0,5] uniform p.dev(2) # 3 +/- 2 gaussian p.soft_range(2,5,2) # 3 in [2,5] uniform with gauss wings p.dev(2, limits=(0,6)) # 3 +/- 2 truncated gaussian p.pdf(lognorm(3, 1)) # lognormal centered on 3, width 1.

  Parameters have hard limits on the possible values, dictated by the model. These bounds apply in addition to any other bounds.

  Parameters can be constrained to be equal to another parameter or parameter expression:

  > a, b = Parameter(3), Parameter(4) p = Parameter(limits=(6, 10)) p.equals(a+b) assert p.nllf() == 0. # within the bounds a.value = 20 assert np.isinf(p.nllf()) # out of bounds

  Constraints on the computed value follow from the constraints on the underlying parameters in addition to any hard limits on the parameter value given by the model.

  Inputs

  value can be a constant, a variable, an expression or a link to another parameter.

  bounds are user-supplied limits on the parameter value within the model. If bounds are supplied then the parameter defaults to fittable.

  distribution is one of Uniform, Normal or UniformSoftBounded classes

  fixed is True if the parameter is fixed, even if bounds are supplied.

  name is the label associated with the parameter in plots. The names need not be unique, but it will be confusing if there are duplicates. The name will usually correspond to the role of the parameter in the model. For models with sequences (e.g., layer numbers), try using a layer name (e.g., based on the material in the layer) rather than a layer number for parameters in that layer. This will make it easier for the user to associate the parameters displayed at the end of the the fit with the layer in the model. Also, when exploring the space of models, the parameter names will be preserved even if a new layer is introduced before the existing layers. That will allow the parameters from the previous fit to be easily used as a seed for the fit to the new model.

  id must be a unique identifier associated with the parameter. This is used to link parameters on save and reload.

  limits are hard limits on the parameter value within the model. Separate from the prior distribution on a random variable provided by the user, the hard limits are restrictions on the value imposed by the model. For example, the thickness of a layer must be zero or more.

  Any additional keyword arguments are preserved as properties of the parameter. For example, tip and units for decorating an input form in the GUI:

  > p = Parameter(10, name=”width”, units=”cm”, tip=”Width of sample”)

  add_prior(distribution: Uniform | Normal | None = None, bounds: Unbounded | Bounded | BoundedAbove | BoundedBelow | BoundedNormal | SoftBounded | Normal | None = None, limits: Tuple[float, float] | None = None)
  add_tag(tag: str)
  arccos()
  arccosh()
  arcsin()
  arcsinh()
  arctan()
  arctan2()
  arctanh()
  bounds: Tuple[float | Literal['-inf'], float | Literal['inf']] | None = None
  static calculation(obj: Parameter | None, name: str, function: Callable[[], float]) → Parameter

    Create a parameter to hold a value derived from the model. This can be used in parameter expressions, for example to constrain total thickness or to set the value in the next segment equal to the value at the end of a freeform segment.

    Note that this function should be called in the __init__ or __post_init__ methods of the class where the parameter is defined, in order to bind the Calculation function to the newly created (or deserialized) Parameter before it is used.

    If obj is a Parameter, use it - otherwise create a new Parameter obj with the given name.

    Then create a Calculation object and attach the evaluator function to the Calculation, and put the Calculation in obj.slot

    Returns obj: Parameter

  ceil()
  clip_set(value)

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

  cos()
  cosh()
  classmethod default(value: float | Tuple[float, float] | Expression | Parameter | Calculation, **kw) → Parameter

    Create a new parameter with the value and kw attributes. If value is already a parameter or expression, set it to that value.

  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: bool = False
  distribution: Uniform | Normal
  equals(expression: Expression | Parameter | Calculation | float)

    Set a parameter equal to another parameter or expression.

    Use `unlink()` to convert from an expression to a variable.

  exp()
  expm1()
  feasible()

    Value is within the limits defined by the model

  property fittable

    Returns True when the argument is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

  property fixed

    Returns True when the argument is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

  floor()
  format()

    Format the parameter, value and range as a string.

  has_prior()
  id: str
  limits: Tuple[float | Literal['-inf'], float | Literal['inf']] = (-inf, inf)
  log()
  log10()
  log1p()
  max()
  min()
  name: str | None = None
  nllf() → float

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

  parameters()
  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.

  prior: Unbounded | Bounded | BoundedAbove | BoundedBelow | BoundedNormal | SoftBounded | Normal | None
  radians()
  randomize(rng=None)

    Set a random value for the parameter.

  range(low, high)

    Allow the parameter to vary within the given range.

  remove_tag(tag: str | None = None)
  reset_prior()
  residual() → float

    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.

  rint()
  round()
  set(value)

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

  sin()
  sinh()
  slot: Variable | Expression | Parameter | Calculation | float
  soft_range(low, high, std)

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

  sqrt()
  tags: List[str]
  tan()
  tanh()
  trunc()
  unlink()
  valid()

    Return true if the parameter is within the valid range.

  property value

class bumps.parameter.ParameterSet(reference: Parameter, names: List[str] | None = None, parameterlist: List[Parameter] | None = None)

  Bases: `object`

  A parameter that depends on the model.

  get_model(index)

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

  names: List[str] | None
  property parameterlist: List[Parameter]
  pm(*args, **kw)

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

  pmp(*args, **kw)

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

  range(*args, **kw)

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

  reference: Parameter
  set_model(index)

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

  to_dict()
  property values

class bumps.parameter.Reference(obj, attr, **kw)

  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.

  NOTE: this class can not be serialized with a dataclass schema TODO: can sasmodels just use Parameter directly?

  add_prior(distribution: Uniform | Normal | None = None, bounds: Unbounded | Bounded | BoundedAbove | BoundedBelow | BoundedNormal | SoftBounded | Normal | None = None, limits: Tuple[float, float] | None = None)
  add_tag(tag: str)
  arccos()
  arccosh()
  arcsin()
  arcsinh()
  arctan()
  arctan2()
  arctanh()
  bounds: Tuple[float | Literal['-inf'], float | Literal['inf']] | None = None
  static calculation(obj: Parameter | None, name: str, function: Callable[[], float]) → Parameter

    Create a parameter to hold a value derived from the model. This can be used in parameter expressions, for example to constrain total thickness or to set the value in the next segment equal to the value at the end of a freeform segment.

    Note that this function should be called in the __init__ or __post_init__ methods of the class where the parameter is defined, in order to bind the Calculation function to the newly created (or deserialized) Parameter before it is used.

    If obj is a Parameter, use it - otherwise create a new Parameter obj with the given name.

    Then create a Calculation object and attach the evaluator function to the Calculation, and put the Calculation in obj.slot

    Returns obj: Parameter

  ceil()
  clip_set(value)

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

  cos()
  cosh()
  classmethod default(value: float | Tuple[float, float] | Expression | Parameter | Calculation, **kw) → Parameter

    Create a new parameter with the value and kw attributes. If value is already a parameter or expression, set it to that value.

  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: bool = False
  distribution: Uniform | Normal
  equals(expression: Expression | Parameter | Calculation | float)

    Set a parameter equal to another parameter or expression.

    Use `unlink()` to convert from an expression to a variable.

  exp()
  expm1()
  feasible()

    Value is within the limits defined by the model

  property fittable

    Returns True when the argument is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

  property fixed

    Returns True when the argument is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

  floor()
  format()

    Format the parameter, value and range as a string.

  has_prior()
  id: str
  limits: Tuple[float | Literal['-inf'], float | Literal['inf']] = (-inf, inf)
  log()
  log10()
  log1p()
  max()
  min()
  name: str | None = None
  nllf() → float

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

  parameters()
  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.

  prior: Unbounded | Bounded | BoundedAbove | BoundedBelow | BoundedNormal | SoftBounded | Normal | None
  radians()
  randomize(rng=None)

    Set a random value for the parameter.

  range(low, high)

    Allow the parameter to vary within the given range.

  remove_tag(tag: str | None = None)
  reset_prior()
  residual() → float

    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.

  rint()
  round()
  set(value)

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

  sin()
  sinh()
  slot: Variable | Parameter | Expression | Calculation | float
  soft_range(low, high, std)

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

  sqrt()
  tags: List[str]
  tan()
  tanh()
  trunc()
  unlink()
  valid()

    Return true if the parameter is within the valid range.

  property value

class bumps.parameter.SupportsPrior

  Bases: `object`

  add_prior(distribution: Uniform | Normal | None = None, bounds: Unbounded | Bounded | BoundedAbove | BoundedBelow | BoundedNormal | SoftBounded | Normal | None = None, limits: Tuple[float, float] | None = None)
  bounds: Unbounded | Bounded | BoundedAbove | BoundedBelow | BoundedNormal | SoftBounded | Normal
  distribution: Uniform | Normal
  has_prior()
  limits: Tuple[float, float]
  prior: Unbounded | Bounded | BoundedAbove | BoundedBelow | BoundedNormal | SoftBounded | Normal | None
  reset_prior()

class bumps.parameter.Uniform

  Bases: `object`

  Uniform distribution with hard boundaries

class bumps.parameter.UniformSoftBounded

  Bases: `object`

  Uniform distribution with error-function PDF on boundaries

  std: float = Field(name=None,type=None,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'description': 'width of the edge distribution'}),kw_only=<dataclasses._MISSING_TYPE object>,_field_type=None)

class bumps.parameter.UserFunction(fn: Callable)

  Bases: `object`

  User-defined functions.

  This is a helper class for the @function decorator, which treats the operator as one of the possible expression operators.

  These won’t be properly serialized/deserialized through the JSON schema unless the function is registered in advance. The schema will not include these functions as possible values even if registered, so a schema validator may fail on one of these functions.

  name: str

class bumps.parameter.ValueProtocol

  Bases: `OperatorMixin`

  Values can be combined to form expressions Provide a suite of operators for creating parameter expressions.

  arccos()
  arccosh()
  arcsin()
  arcsinh()
  arctan()
  arctan2()
  arctanh()
  ceil()
  cos()
  cosh()
  degrees()
  exp()
  expm1()
  fittable: bool = False
  fixed: bool = True
  floor()
  log()
  log10()
  log1p()
  max()
  min()
  parameters() → List[Parameter]
  radians()
  rint()
  round()
  sin()
  sinh()
  sqrt()
  tan()
  tanh()
  trunc()
  value: float

class bumps.parameter.Variable(value: float)

  Bases: `ValueProtocol`

  Saved state for a random variable in the model.

  arccos()
  arccosh()
  arcsin()
  arcsinh()
  arctan()
  arctan2()
  arctanh()
  ceil()
  cos()
  cosh()
  degrees()
  exp()
  expm1()
  fittable: bool = False
  fixed: bool = True
  floor()
  log()
  log10()
  log1p()
  max()
  min()
  parameters()
  radians()
  rint()
  round()
  sin()
  sinh()
  sqrt()
  tan()
  tanh()
  trunc()
  value: float

bumps.parameter.acos(*args)

bumps.parameter.acosd(*args: Parameter | Expression | Calculation | float)

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

bumps.parameter.acosh(*args)

bumps.parameter.arccosd(*args: Parameter | Expression | Calculation | float)

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

bumps.parameter.arcsind(*args: Parameter | Expression | Calculation | float)

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

bumps.parameter.arctan2d(*args: Parameter | Expression | Calculation | float)

  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(*args: Parameter | Expression | Calculation | float)

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

bumps.parameter.asin(*args)

bumps.parameter.asind(*args: Parameter | Expression | Calculation | float)

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

bumps.parameter.asinh(*args)

bumps.parameter.atan(*args)

bumps.parameter.atan2(*args)

bumps.parameter.atan2d(*args: Parameter | Expression | Calculation | float)

  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(*args: Parameter | Expression | Calculation | float)

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

bumps.parameter.atanh(*args)

bumps.parameter.copy_linked(has_parameters, free_names=None)
  make a copy of an object with parameters

    - then link all the parameters, except

    - those with names matching “free_names”

bumps.parameter.cosd(*args: Parameter | Expression | Calculation | float)

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

bumps.parameter.current(s: List[Parameter])

bumps.parameter.fittable(s)

  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)

bumps.parameter.format(p, indent=0, freevars=None, field=None)

  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(fn: Callable)

  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.max(Parameter)

bumps.parameter.min(Parameter)

bumps.parameter.priors(s: List[Parameter]) → List[Parameter]

  Return the list of parameters (fitted or computed) that have prior probabilities associated with them. This includes all varying parameters, plus expressions (including simple links), but ignoring constants and fixed parameters whose probabilities won’t change the fits.

bumps.parameter.randomize(s: List[Parameter])

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

bumps.parameter.sind(*args: Parameter | Expression | Calculation | float)

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

bumps.parameter.substitute(a)

  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)

  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.tag_all(parameter_tree, tag, remove=False)

bumps.parameter.tand(*args: Parameter | Expression | Calculation | float)

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

bumps.parameter.test_operator()

bumps.parameter.to_dict(p)

bumps.parameter.unique(s) → List[Parameter]

  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.untag_all(parameter_tree, tag: str | None = None)

bumps.parameter.varying(s: List[Parameter]) → List[Parameter]

  Return the list of fitted parameters in the model.

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