Parameter distributions

Parameter distributions sample scalar model parameters. For spatial disorder and finite correlation lengths in particle structures, see correlation profiles.

Constructors

A distribution is constructed by one of the following:

distr = ba.DistributionGate(start, stop, n_samples=25)
distr = ba.DistributionCosine(mean, hwhm, n_samples=25)
distr = ba.DistributionGaussian(mean, std_dev, n_samples=25,
                                rel_sampling_width=2)
distr = ba.DistributionLorentz(mean, hwhm, n_samples=25,
                               rel_sampling_width=2)
distr = ba.DistributionLogNormal(median, scale_param, n_samples=25,
                                 rel_sampling_width=2)

Sampling

Sampling can also be configured after construction:

distr = ba.DistributionGaussian(10*nm, 1*nm)
distr.setNSamples(51)
distr.setRelSamplingWidth(3)

This gives 51 equally spaced values from 7 to 13 nm. setNSamples(n) sets the requested positive number of samples. A zero-width distribution returns a single sample.

setRelSamplingWidth(w) sets a dimensionless half-range multiplier: the standard deviation for a Gaussian, or the HWHM for a Lorentzian. For a log-normal distribution, the bounds are median * exp(-w * scale_param) and median * exp(w * scale_param). DistributionGate and DistributionCosine ignore this setting.

The returned weights sum to one over the sampled interval. Configure the distribution before passing it to a beam or detector setting.

Usage

Parameter distributions are either supplied to beam divergence or detector resolution classes as described there, or they are used programmatically.

In programmatic usage, the function call

parsamples = distr.distributionSamples()

returns a vector of parameter samples. Each ParameterSample has a value and a weight. A particle Mixture can represent the resulting incoherent sum of components.

As in the Polydisperse cylinders example listed below, radius samples can become particle variants in a dilute mixture:

distr = ba.DistributionGaussian(10*nm, 1*nm)
mixture = ba.Mixture()
for parsample in distr.distributionSamples():
    ff = ba.Cylinder(parsample.value, 5*nm)
    particle = ba.Particle(particle_mat, ff)
    mixture.addParticle(particle, parsample.weight)

layer.deposit2D(ba.Dilute2D(0.001/nm2, mixture))

Mixture normalizes the sample weights. The Dilute2D density is therefore the total areal density across all radii.

Examples