Reference

Functions to extend with a new model

LaplacianExpectationMaximization.sampleFunction
sample(rng, data, model, parameters; kw...)

Takes already generated data as input and returns a new data point. This function is called in the simulate function. Keyword arguments are passed through the simulate function.

source

Population model

Fitting

LaplacianExpectationMaximization.maximize_logpFunction
maximize_logp(data, model, parameters = parameters(model);
              fixed = (;)
              coupled = [],
              lambda_l2 = 0.,
              hessian_ad = AutoForwardDiff(),
              gradient_ad = AutoForwardDiff(),
              evaluate_training = false,
              evaluate_test_data = nothing,
              evaluation_trigger = EventTrigger(),
              evaluation_options = (;),
              optimizer_options = (;),
              optimizer = default_optimizer(model, parameters; fixed, optimizer_options...),
              callbacks = [],
              verbosity = 1, print_interval = 3,
              return_g! = false,
              kw...
              )
source

Optimizers

LaplacianExpectationMaximization.OptimizerType
Optimizer(; optimizer = OptimOptimizer(Optim.LBFGS()), finetuner = nothing, fallback = OptimisersOptimizer())

Default optimizer. finetuner can be another optimizer that is called after the first optimizer finished. The fallback optimizer is called, if the optimizer or finetuner fails.

Can also be constructed as

Optimizer(optimizer; finetuner = nothing, fallback = OptimisersOptimizer(), kw...)

where optimizer can be a symbol (to use NLopt), or an optimiser from Optim or Optimiser. See also NLoptOptimizer, OptimOptimizer, OptimisersOptimizer.

source
LaplacianExpectationMaximization.OptimisersOptimizerType
OptimisersOptimizer(opt; maxeval = 10^5, maxtime = Inf, min_grad_norm = 1e-8, lower_bounds = -Inf, upper_bounds = Inf)

Optimizer opt can be anything from subtypes(Optimisers.AbstractRule). Optimization stops, when the L2-norm of the gradient falls below min_grad_norm or maxeval or maxtime is reached. See also Optimisers.

source

Simulation

LaplacianExpectationMaximization.simulateFunction
simulate(
    model,
    parameters;
    n_steps,
    stop,
    init,
    tracked,
    rng,
    kw...
)

Returns a named tuple (; data, logp). stop(data, i) is a boolean function that depends on the sequence of simulated data and the iteration counter i. If tracked = true the state of the model is saved for every step in the simulation. Additional keyword arguments kw are passed to the sample function.

source

Evaluation

LaplacianExpectationMaximization.mc_marginal_logpFunction
mc_marginal_logp(data, model::PopulationModel, params;
                 repetitions = 20, n_samples = 10^4, rng = Random.default_rng())

Estimate the marginal log probability of the data given a model by sampling from the population.

source

Derivatives