Distributions#
Header obdeect/sources/density.hpp, namespace obdeect::sources. Uniforms = std::array<double,4>; sample(u)
of 1-D shapes uses u[0] (complex pulse u[0..2]).
LinearDensity#
Unnormalised density, piecewise linear between nodes (x_i, y_i), zero outside
[x_0, x_n]. Constructor error (invalid_argument): fewer than 2 nodes, size mismatch, a
non-finite value, y < 0, non-increasing x, or integral <= 0. Default-constructed =
empty = point mass at 0 (sample returns 0, cdf 0, integral 0).
cdf(x): integral fromx_0tox(trapezoid per segment; within a segmentC_i + y_i s + k s^2/2,s = x - x_i,kthe slope); 0 below, total above.sample(p)forp in (0,1): thexwithcdf(x) = p * integral(solve the segment quadratic stably for any slope, clamp to the segment).at(x),maximum(),integral(),lower(),upper().Example: nodes
{0,1,3}, values{0,2,2}: integral 5,sample(0.1) = sqrt(0.5),sample(0.6) = 2,sample(1.0) = 3,cdf(2) = 3.
Normal quantile#
normal_quantile(p): inverse standard-normal CDF to relative error ~1e-15 (reference:
0.975 -> 1.959963984540054, 1e-6 -> -4.753424308822899, 0.5 -> 0). Used by Gaussian
shapes: x = mean + sigma * normal_quantile(u).
1-D shapes (pulses in ns, spectra in nm)#
Shape |
Parameters |
Sample from |
Mean / variance |
|---|---|---|---|
Fixed |
value |
|
value / 0 |
UniformRange |
low, high |
|
(low+high)/2 / (high-low)^2/12 |
GaussianShape |
mean, sigma |
|
mean / sigma^2 |
Exponential |
mean, tau |
|
mean / tau^2 |
ComplexPulse |
flat, rms, decay, delay |
|
delay / flat^2/12 + rms^2 + decay^2 |
InverseSquare |
low, high |
|
|
Tabulated |
LinearDensity |
|
from table |
Spectrum = Fixed | UniformRange | InverseSquare | Tabulated;
Pulse = Fixed | UniformRange | GaussianShape | Exponential | ComplexPulse | Tabulated. All
members sample, mean, variance (not Tabulated) are public. Moments agree with the sampled
values within four sigma.
Angular profiles#
Argument u = 1 - cos(theta). Each profile has intensity(u) (relative per solid angle),
maximum(), integral() (over u), cdf(u) (emitted fraction below u), quantile(p).
Profile |
intensity |
integral |
cdf |
quantile |
|---|---|---|---|---|
Isotropic |
1 on [0,2] |
2 |
clamp(u/2,0,1) |
2p |
FixedAngle(u0) |
none (0) |
0 |
1 if u >= u0 else 0 |
u0 |
FilledCone(u0) |
1 on [0,u0] |
u0 |
clamp(u/u0,0,1) |
p u0 |
Lambertian |
1-u on [0,1] |
1/2 |
2v - v^2, v = clamp(u,0,1) |
1 - sqrt(1-p) |
TabulatedAngular(LinearDensity over u) |
table |
table |
cdf/integral |
density.sample(p) |
Angular is the variant of these five. Helpers intensity_maximum, angle_quantile,
integral(Angular).
gaussian_angular_table(sigma_rad): intensityexp(-theta^2/(2 sigma^2)), nodes attheta = 0, 0.05 sigma, 0.10 sigma, ...belowtheta_max = min(5 sigma, pi)(nodes computed by repeated addition of0.05 sigmastarting at 0, whiletheta < theta_max) plus a last node attheta_max;u = 1 - cos(theta). Error ifsigma < 1e-12rad or non-finite (message mentions 1e-12 rad).sigmais the 2-D r.m.s. in angle: the fittedsqrt(mean(theta^2)/2)equals sigma (sigma 5 deg within 2%). Intensity atu(sigma)isexp(-1/2)to 1e-3 and atu = 0is 1.rayleigh_angular_table(): intensity0.5 (1 + cos^2 theta), nodes every 1 deg from 0 to 180 deg (181 nodes),u = 1 - cos(theta).