fluopy.distributions¶
Random variable distributions.
Classes¶
Model to describe photoswitching fingerprints produced by n fluorophores where there |
|
Model to describe a mixture of exponential distributions. |
|
Model to describe the marginal distribution of a sample X from a mixture of |
Functions¶
CDF of the hypoexponential distribution. |
|
PDF of the hypoexponential distribution. |
|
First order derivative of the PDF of the hypoexponential distribution. |
|
Second order derivative of the PDF of the hypoexponential distribution. |
|
Get combinations of lambdas and pis for the photoswitching fingerprint model. |
|
|
Generate combinations for all valid convolutions of exponential distributions. |
|
Map combinations to lambdas. |
|
Get pis for each combination. |
Module Contents¶
- fluopy.distributions.hypoexponential_distribution_cdf(x: float | numpy.typing.ArrayLike, *args: Any) float | numpy.typing.NDArray[numpy.float64][source]¶
CDF of the hypoexponential distribution.
- Parameters:
x – Sample.
args (float, 1-D array_like) – Parameters (lambdas) of the hypoexponential distribution. Must be distinct and positive.
- Returns:
CDF of the hypoexponential distribution.
- Return type:
float | npt.NDArray[np.float64]
- fluopy.distributions.hypoexponential_distribution_pdf(x: float | numpy.typing.ArrayLike, *args: Any) float | numpy.typing.NDArray[numpy.float64][source]¶
PDF of the hypoexponential distribution.
- Parameters:
x – Sample.
args (float, 1-D array_like) – Parameters (lambdas) of the hypoexponential distribution. Must be distinct and positive.
- Returns:
PDF of the hypoexponential distribution.
- Return type:
float | npt.NDArray[np.float64]
- fluopy.distributions.hypoexponential_distribution_pdf_1st_order_derivative(x: float | numpy.typing.ArrayLike, *args: Any) float | numpy.typing.NDArray[numpy.float64][source]¶
First order derivative of the PDF of the hypoexponential distribution.
- Parameters:
x – Sample.
args (float, 1-D array_like) – Parameters (lambdas) of the hypoexponential distribution. Must be distinct and positive.
- Returns:
First order derivative of the PDF of the hypoexponential distribution.
- Return type:
float | npt.NDArray[np.float64]
- fluopy.distributions.hypoexponential_distribution_pdf_2nd_order_derivative(x: float | numpy.typing.ArrayLike, *args: Any) float | numpy.typing.NDArray[numpy.float64][source]¶
Second order derivative of the PDF of the hypoexponential distribution.
- Parameters:
x – Sample.
args (float, 1-D array_like) – Parameters (lambdas) of the hypoexponential distribution. Must be distinct and positive.
- Returns:
Second order derivative of the PDF of the hypoexponential distribution.
- Return type:
float | npt.NDArray[np.float64]
- class fluopy.distributions.Photoswitching_fingerprint_model(params: dict, weights: float | numpy.typing.ArrayLike | None = None, domain: tuple[float, float] = (0, np.inf))[source]¶
Model to describe photoswitching fingerprints produced by n fluorophores where there is bias in time (e.g., increased probability of ON in the beginning).
- params¶
- weights¶
- domain¶
- z¶
- pdf_part(call: collections.abc.Callable | None, x: float | numpy.typing.ArrayLike, i: int, normalize: bool = False) float | numpy.typing.NDArray[numpy.float64][source]¶
PDF for the arrival times (not delta arrival times) after the i-th fluorophore has photobleached.
- Parameters:
call – Function to calculate the PDF (or its derivative) of the hypoexponential distribution. If None, hypoexponential_distribution_pdf is used.
x – Sample.
i – Index of the fluorophore that has just photobleached (0 means no photobleaching so far).
normalize – Whether to normalize the PDF part to the domain. This is needed since if PDF parts are summarized into the full PDF, the full PDF is normalized. If PDF parts are used for other purposes (e.g., marginal distribution), they have to be normalized individually.
- Returns:
PDF for the arrival times
- Return type:
float | npt.NDArray[np.float64]
- pdf(x: float | numpy.typing.ArrayLike, order: int = 0) float | numpy.typing.NDArray[numpy.float64][source]¶
PDF
- Parameters:
x – Sample.
order (int) – Order of the derivative of the PDF to be calculated.
- Returns:
PDF
- Return type:
float | npt.NDArray[np.float64]
- cdf_part(x: float | numpy.typing.ArrayLike, i: int, normalize: bool = False) float | numpy.typing.NDArray[numpy.float64][source]¶
CDF for the arrival times (not delta arrival times) after the i-th fluorophore has photobleached.
- Parameters:
x – Sample.
i – Index of the fluorophore that has just photobleached (0 means no photobleaching so far).
normalize – Whether to normalize the CDF part to the domain. This is needed since if CDF parts are summarized into the full CDF, the full CDF is normalized. If CDF parts are used for other purposes (e.g., marginal distribution), they have to be normalized individually.
- Returns:
CDF for the arrival times
- Return type:
float | npt.NDArray[np.float64]
- cdf(x: float | numpy.typing.ArrayLike, extra: bool = False) float | numpy.typing.NDArray[numpy.float64][source]¶
CDF
- Parameters:
x – Sample.
extra – If True, the CDF is not normalized to the domain. Needed for normalization of PDF and CDF.
- Returns:
CDF
- Return type:
float | npt.NDArray[np.float64]
- dpdf(x: float | numpy.typing.ArrayLike) float | numpy.typing.NDArray[numpy.float64][source]¶
First derivative of PDF.
- Parameters:
x – Sample.
- Returns:
First derivative of PDF
- Return type:
float | npt.NDArray[np.float64]
- ddpdf(x: float | numpy.typing.ArrayLike) float | numpy.typing.NDArray[numpy.float64][source]¶
Second derivative of PDF.
- Parameters:
x – Sample.
- Returns:
Second derivative of PDF
- Return type:
float | npt.NDArray[np.float64]
- fluopy.distributions.photoswitching_fingerprint_prepare(params: dict, n: int, z: int) tuple[numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.float64]][source]¶
Get combinations of lambdas and pis for the photoswitching fingerprint model. Needed for the PDF and CDF parts. See model derivation for details.
- Parameters:
params – Parameters of the underlying exponential distributions.
n – Number of fluorophores needed to be considered. For the i-th CDF/PDF part, n = i + 1.
z – Index of the delta arrival time group that uses a mixture of three exponential distributions. -1 if none uses three exponential distributions.
- Returns:
Combinations of lambdas and pis for the photoswitching fingerprint model.
- Return type:
tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]
- fluopy.distributions.generate_combinations(n: int, z: int) numpy.typing.NDArray[numpy.int64][source]¶
Generate combinations for all valid convolutions of exponential distributions.
- Parameters:
n – Number of fluorophores needed to be considered. For the i-th CDF/PDF part, n = i + 1.
z – Index of the delta arrival time group that uses a mixture of three exponential distributions. -1 if none uses three exponential distributions.
- Returns:
All valid combinations of exponential distributions. Array of shape (m, n) where m is the number of valid combinations. For each m, the n columns represent the n delta arrival time groups needed to be considered. Each entry can be 0 (biased exponential distribution), 1 (non-biased exponential distribution of two-component mixture), 2 (first non-biased exponential distribution of three-component mixture), or 3 (second non-biased exponential distribution of three-component mixture).
- Return type:
npt.NDArray[np.int64]
- fluopy.distributions.map_to_lambdas(combos: numpy.typing.NDArray[numpy.int_], params: dict, z: int) numpy.typing.NDArray[numpy.float64][source]¶
Map combinations to lambdas.
- Parameters:
combos – All valid combinations of exponential distributions.
params – Parameters of the underlying exponential distributions.
z – Index of the fluorophore that uses three exponential distributions.
- Returns:
Mapped lambdas. Array of shape (m, n) where m is the number of valid combinations and n the number of delta arrival time groups needed to be considered.
- Return type:
npt.NDArray[np.float64]
- fluopy.distributions.get_pis(combos: numpy.typing.NDArray[numpy.int_], params: dict, z: int) numpy.typing.NDArray[numpy.float64][source]¶
Get pis for each combination.
- Parameters:
combos – All valid combinations of exponential distributions.
params – Parameters of the underlying exponential distributions.
z – Index of the fluorophore that uses three exponential distributions.
- Returns:
Mapped pis. Array of shape (m, n) where m is the number of valid combinations and n the number of delta arrival time groups needed to be considered.
- Return type:
npt.NDArray[np.float64]
- class fluopy.distributions.ExponentialMixtureModel(params: dict, domain: tuple[float, float] = (0, np.inf))[source]¶
Model to describe a mixture of exponential distributions.
- params¶
- domain¶
- pdf(x: float | numpy.typing.ArrayLike) float | numpy.typing.NDArray[numpy.float64][source]¶
Probability density function of a mixture of exponential distributions.
- Parameters:
x – Sample.
- Returns:
PDF of the mixture of exponential distributions.
- Return type:
float | npt.NDArray[np.float64]
- cdf(x: float | numpy.typing.ArrayLike, extra: bool = False) float | numpy.typing.NDArray[numpy.float64][source]¶
Cumulative distribution function of a mixture of exponential distributions.
- Parameters:
x – Sample.
extra –
…
- Returns:
CDF of the mixture of exponential distributions.
- Return type:
float | npt.NDArray[np.float64]
- class fluopy.distributions.ExponentialMixtureMarginalModel(params: dict, pfa_cdf_part: collections.abc.Callable, cdf_part_index: int, truncation_up: float)[source]¶
Model to describe the marginal distribution of a sample X from a mixture of exponential distributions, where the upper truncation is a random variable Y ~ fixed truncation - T, and T is a random variable following a part of PFA distribution.
- pdf_grid¶
- cdf_grid¶
- x_grid¶
- P_obs¶