# Bumps documentation

## initpop - Population initialization strategies

`generate` | Population initializer.
`cov_init` | Initialize n sets of random variables from a gaussian model.
`eps_init` | Generate a random population using an epsilon ball around the current value.
`lhs_init` | Latin hypercube sampling.
`random_init` | Generate a random population from the problem parameters.

Population initialization strategies.

To start the analysis an initial population is required. This will be an array of size M x N, where M is the number of dimensions in the fitting problem and N is the number of individuals in the population.

Normally the initialization will use a call to `generate()` with key-value pairs from the command line options. This will include the ‘init’ option, with the name of the strategy used to initialize the population.

Additional strategies like uniform box in [0,1] or standard norm (rand(m,n) and randn(m,n) respectively), may also be useful.

bumps.initpop.cov_init(n: int, initial: ndarray, bounds: ndarray, use_point: bool = False, cov: ndarray | None = None, dx: ndarray | None = None) → ndarray

  Initialize n sets of random variables from a gaussian model.

  The center is at x with an uncertainty ellipse specified by the 1-sigma independent uncertainty values dx or the full covariance matrix uncertainty cov.

  For example, create an initial population for 20 sequences for a model with local minimum x with covariance matrix C:

      pop = cov_init(cov=C, pars=p, n=20)

  If use_point is True, then the current value of the parameters is returned as the first point in the population.

bumps.initpop.eps_init(n: int, initial: ndarray, bounds: ndarray, use_point: bool = False, eps: float = 1e-06) → ndarray

  Generate a random population using an epsilon ball around the current value.

  Since the initial population is contained in a small volume, this method is useful for exploring a local minimum around a point. Over time the ball will expand to fill the minimum, and perhaps tunnel through barriers to nearby minima given enough burn-in time.

  eps is in proportion to the bounds on the parameter, or the current value of the parameter if the parameter is unbounded. This gives the initialization a bit of scale independence.

  If use_point is True, then the current value of the parameters is returned as the first point in the population.

bumps.initpop.generate(problem: Any, init: str = 'eps', pop: int = 10, use_point: bool = True, **options: ...) → np.ndarray

  Population initializer.

  problem is a fit problem with getp and bounds methods.

  init is ‘eps’, ‘cov’, ‘lhs’ or ‘random’, indicating which initializer should be used.

  pop is the population scale factor, generating pop individuals for each parameter in the fit. If pop < 0, generate a total of -pop individuals regardless of the number of parameters.

  use_point is True if the initial value should be a member of the population.

  Additional options are ignored so that generate can be called using all command line options.

bumps.initpop.lhs_init(n: int, initial: ndarray, bounds: ndarray, use_point: bool = False) → ndarray

  Latin hypercube sampling.

  Returns an array whose columns and rows each have n samples from equally spaced bins between bounds=(xmin, xmax) for the column. Unlike random, this method guarantees a certain amount of coverage of the parameter space. Consider, though that the diagonal matrix satisfies the LHS condition, and you can see that the guarantees are not very strong. A better methods, similar to sudoku puzzles, would guarantee coverage in each block of the matrix, but this is not yet implmeneted.

  If use_point is True, then the current value of the parameters is returned as the first point in the population, preserving the the LHS property.

bumps.initpop.random_init(n, initial, bounds, use_point=False, problem=None)

  Generate a random population from the problem parameters.

  Values are selected at random from the bounds of the problem according to the underlying probability density of each parameter. Uniform semi-definite and indefinite bounds use the standard normal distribution for the underlying probability, with a scale factor determined by the initial value of the parameter.

  If use_point is True, then the current value of the parameters is returned as the first point in the population.