tolerancing.perturbation
Perturbation Module
This module contains classes for generating perturbations to optical system variables. Perturbations are used to simulate the effects of manufacturing errors or other sources of variability in an optical system.
Kramer Harrison, 2024
Classes
Abstract base class for samplers. |
|
|
A sampler that generates random samples from a given distribution. Options for the distribution include 'normal' and 'uniform' and these require arguments as follows: "normal": loc, scale (corresponding to mean and standard deviation) "uniform": low, high. |
|
A class representing a perturbation to an optic variable. |
|
A sampler that generates a range of samples over a linear range. |
|
A sampler that always returns a fixed scalar value. |
- class BaseSampler[source]
Abstract base class for samplers.
This class defines the interface for samplers in the optiland.tolerancing module.
- class DistributionSampler(distribution, seed=None, **params)[source]
A sampler that generates random samples from a given distribution. Options for the distribution include ‘normal’ and ‘uniform’ and these require arguments as follows:
“normal”: loc, scale (corresponding to mean and standard deviation) “uniform”: low, high
- Parameters:
distribution (str) – The type of distribution to sample from. Options are ‘normal’ and ‘uniform’.
*params – Variable length arguments representing the parameters of the distribution.
seed (int, optional) – The seed value for random number generation. Defaults to None.
- Raises:
ValueError – If the distribution type is unknown.
- class Perturbation(optic, variable_type, sampler, **kwargs)[source]
A class representing a perturbation to an optic variable. Perturbations are used to simulate the effects of manufacturing errors or other sources of variability in an optical system.
- Parameters:
optic – The optic object to apply the perturbation to.
variable_type – The type of variable to perturb.
sampler – The sampler object used to generate perturbation values.
**kwargs – Additional keyword arguments to be passed to the Variable object.
- optic
The optic object to apply the perturbation to.
- type
The type of variable to perturb.
- sampler
The sampler object used to generate perturbation values.
- variable
The Variable object representing the perturbed variable.
- value
The value of the perturbation.
- class RangeSampler(start, end, steps)[source]
A sampler that generates a range of samples over a linear range.
- Parameters:
start (float or int) – The start of the range.
end (float or int) – The end of the range.
steps (int) – The number of samples to generate.
- start
The start of the range.
- Type:
float or int
- end
The end of the range.
- Type:
float or int
- size
The number of samples to generate.
- Type:
int
- class ScalarSampler(value)[source]
A sampler that always returns a fixed scalar value.
- Parameters:
value (float or int) – The scalar value to be returned by the sampler.
- value
The scalar value to be returned by the sampler.
- Type:
float or int
- size
The size of the sample, which is always 1 for ScalarSampler.
- Type:
int