leaspy.models.shared_speed_logistic#

Classes#

SharedSpeedLogisticModel

Logistic model for multiple variables of interest, imposing same average

Module Contents#

class SharedSpeedLogisticModel(name, **kwargs)#

Bases: leaspy.models.logistic.LogisticInitializationMixin, leaspy.models.time_reparametrized.TimeReparametrizedModel

Logistic model for multiple variables of interest, imposing same average evolution pace for all variables (logistic curves are only time-shifted).

Parameters:
namestr

The name of the model.

**kwargs

Hyperparameters of the model.

Parameters:

name (str)

static metric(*, g_deltas_exp)#

Compute the metric term for the logistic model.

This scaling term modulates the curvature of the logistic trajectory.

Parameters:
g_deltas_exptorch.Tensor

Product of slope and exp(-deltas).

Returns:
torch.Tensor

Metric value, computed as:

\[\frac{(g \cdot e^{-\delta} + 1)^2}{g \cdot e^{-\delta}}\]
Parameters:

g_deltas_exp (Tensor)

Return type:

Tensor

static deltas_exp(*, deltas_padded)#

Compute the exponential of the negative deltas.

Parameters:
deltas_paddedtorch.Tensor

Padded deltas.

Returns:
torch.Tensor

Exponential of the negative deltas.

Parameters:

deltas_padded (Tensor)

Return type:

Tensor

static g_deltas_exp(*, g, deltas_exp)#
Parameters:
Return type:

Tensor

static pad_deltas(*, deltas)#

Prepend deltas with a zero as delta_1 is set to zero in the equations.

Parameters:
deltastorch.Tensor

Deltas tensor.

Returns:
torch.Tensor

Padded deltas tensor.

Parameters:

deltas (Tensor)

Return type:

Tensor

static denom(*, g_deltas_exp)#

Compute the denominator for the \(\gamma_{t_0}\) calculation.

Parameters:

g_deltas_exp (Tensor)

Return type:

Tensor

static gamma_t0(*, denom)#

Compute the \(\gamma_{t_0}\) value, which is the inverse of the denominator.

Parameters:
denomtorch.Tensor

Denominator term.

Returns:
torch.Tensor

\(\gamma_{t_0}\) value.

Parameters:

denom (Tensor)

Return type:

Tensor

static g_metric(*, gamma_t0)#

Compute the g_metric value, which is the square of gamma_t0.

Parameters:
gamma_t0torch.Tensor

\(\gamma_{t_0}\) value.

Returns:
torch.Tensor

\(g_{metric}\) value, computed as:

\[g\_metric = \frac{1}{(\gamma_{t0} \cdot (1 - \gamma_{t0}))^2}\]
Parameters:

gamma_t0 (Tensor)

Return type:

Tensor

static collin_to_d_gamma_t0(*, deltas_exp, denom)#

Compute the collinear term to d_gamma_t0.

Parameters:
deltas_exptorch.Tensor

Exponential of the negative deltas.

denomtorch.Tensor

Denominator term.

Returns:
torch.Tensor

Collinear term to d_gamma_t0

Parameters:
Return type:

Tensor

classmethod model_with_sources(*, rt, space_shifts, metric, deltas_padded, log_g)#

Returns a model with sources.

Parameters:
  • rt (leaspy.utils.weighted_tensor.TensorOrWeightedTensor[float])

  • space_shifts (leaspy.utils.weighted_tensor.TensorOrWeightedTensor[float])

  • metric (leaspy.utils.weighted_tensor.TensorOrWeightedTensor[float])

  • deltas_padded (leaspy.utils.weighted_tensor.TensorOrWeightedTensor[float])

  • log_g (leaspy.utils.weighted_tensor.TensorOrWeightedTensor[float])

Return type:

Tensor

classmethod model_no_sources(*, rt, metric, deltas_padded, log_g)#

Returns a model without sources.

Parameters:
  • rt (leaspy.utils.weighted_tensor.TensorOrWeightedTensor[float])

  • metric (leaspy.utils.weighted_tensor.TensorOrWeightedTensor[float])

  • deltas_padded (leaspy.utils.weighted_tensor.TensorOrWeightedTensor[float])

  • log_g (leaspy.utils.weighted_tensor.TensorOrWeightedTensor[float])

Return type:

Tensor

get_variables_specs()#

Get the specifications of the variables used in the model.

Return type:

NamedVariables