qspec logo qspec logo

A physics toolbox for laser spectroscopy.

Static Badge Static Badge Static Badge

Static Badge Static Badge

© 2026 Patrick Müller. All rights reserved.

qspec. combined_pdf  (  z ,  pdf_1=pdf ,  pdf_2=pdf ,  loc_1=0.0 ,  scale_1=1.0 ,  loc_2=0.0 ,  scale_2=1.0 ,  operator='+' ,  n=10  )[source]

The probability density function (pdf) of the sum or the product of two random variates $X$ and $Y$

$$ \rho_Z(z) = \begin{cases}\int\rho_X(x)\,\rho_Y(z - x)\,\mathrm{d}x, & Z = X + Y\\ \int\rho_X(x)\,\rho_Y(z / x)\,\frac{1}{|x|}\,\mathrm{d}x, & Z = XY\end{cases}, $$

calculated by numerical integration.

Parameters:
zarray_like

The quantiles $z$ of the combined pdf.

pdf_1Callable

The pdf $\rho_X$ of the first random variate.

pdf_2Callable

The pdf $\rho_Y$ of the second random variate.

loc_1float

The loc parameter of the first pdf.

scale_1float

The scale parameter of the first pdf.

loc_2float

The loc parameter of the second pdf.

scale_2float

The scale parameter of the second pdf.

operatorstr

The operator that defines the new random variate $Z$. Can be either "+" or "*".

nint

The precision of the numerical integration, which uses 2**n intervals.

Returns:
rho_zndarray

The value of the pdf $\rho_Z$ at the given z quantiles.

Raises:
ValueError

If operator is not supported.