Distributions

class lightworks.interferometers.dists.Constant(value: float)

Bases: Distribution

Implements returns of a singular constant value for the assigned quantity.

Parameters:

value (float) – The constant value to use.

set_random_seed(seed: int | None) None

Used for setting the random seed for the model.

value() float

Returns set constant value.

class lightworks.interferometers.dists.Distribution

Bases: ABC

Base class for all distributions. Enforces that any created distributions have the required value method, which returns a singular value on request. If the distribution requires randomness, then the set_random_seed method should be added, which accepts a seed and sets this for the rng to allow for repeatability where required.

abstract set_random_seed(seed: int | None) None

Used for setting the random seed for the model. Can just pass in cases where a distribution does not feature a random component.

abstract value() float

Returns a value from the distribution on request.

class lightworks.interferometers.dists.Gaussian(center: float, deviation: float, min_value: float | None = None, max_value: float | None = None)

Bases: Distribution

Returns random values according to a Gaussian distribution with defined center and standard deviation. It can also be constrained to be between a minimum and maximum value to prevent issues with assigning invalid quantities. When a value is outside of the set bounds the distribution will be resampled until this is no longer the case. Note: care should be taken with setting minimum and maximum values as setting these to be too strict could significantly increase the time taken to produce a valid value.

Parameters:
  • center (float) – The center (mean) of the Gaussian distribution.

  • deviation (float) – The standard deviation of the distribution.

  • min_value (float | None) – The minimum allowed value for the distribution. Defaults to None, which will assign the min value to be - infinity.

  • max_value (float | None) – The maximum allowed value for the distribution. Defaults to None, which will assign the max value to be + infinity.

set_random_seed(seed: int | None) None

Used for setting the random seed for the model.

value() float

Returns random value from the Gaussian distribution.

class lightworks.interferometers.dists.TopHat(min_value: float, max_value: float)

Bases: Distribution

Returns random value according to a uniform distribution between two values.

Parameters:
  • min_value (float) – The minimum value of the distribution.

  • max_value (float) – The maximum value of the distribution.

set_random_seed(seed: int | None) None

Used for setting the random seed for the model.

value() float

Returns random value from within set range.