Skip to content

fit.sampling

Sampling of the start values of a fit, on the designs of sbmlsim.simulation.sampling.

The values for a seed are the ones of the sampling before it.

SamplingType

Bases: Enum

Type of sampling used.

The LHS options are latin hypercube sampling types. START does not sample: every run starts from the start values of the parameters, which is what a fit needs when the start values are a solution to improve, e.g. the nominal values of a model or the trained network of a hybrid problem, instead of a point of the bounds. The runs are identical then, so one run is enough for a local optimizer.

is_log property

is_log

Check if the samples are drawn in logarithmic space.

is_lhs property

is_lhs

Check if latin hypercube sampling is used.

create_samples

create_samples(
    parameters,
    size,
    sampling=LOGUNIFORM,
    seed=None,
    min_bound=1e-10,
)

Create samples of start values from the bounds of the parameters.

With SamplingType.START every sample is the vector of the start values of the parameters and the bounds and the seed are not used.

A parameter with an infinite bound has no interval to sample: it starts from its start value in every sample, so the samples differ in the parameters with finite bounds. The samples of these do not depend on the parameters which are not sampled.

A parameter on the linear scale (FitParameter.scale), e.g. an element of a neural network with negative bounds, is sampled uniformly in its bounds whatever the sampling type; a parameter without a scale of its own follows the sampling type. Logarithmic sampling requires positive bounds, non-positive lower bounds are replaced by min_bound.

Parameters:

Name Type Description Default
parameters list[FitParameter]

parameters to sample, the bounds define the sampled interval.

required
size int

number of samples.

required
sampling SamplingType

type of sampling.

LOGUNIFORM
seed int | None

seed of the random number generator, for reproducible samples.

None
min_bound float

hard lower bound, replaces a non-positive bound of a logarithmic sampling.

1e-10

Returns:

Type Description
DataFrame

DataFrame with one row per sample and one column per parameter.

Raises:

Type Description
ValueError

if the sampling type is unsupported, the bounds are invalid, or a parameter with an infinite bound has no start value (with SamplingType.START a parameter without a start value).