fluopy.distributions ==================== .. py:module:: fluopy.distributions .. autoapi-nested-parse:: Random variable distributions. Classes ------- .. autoapisummary:: fluopy.distributions.Photoswitching_fingerprint_model fluopy.distributions.ExponentialMixtureModel fluopy.distributions.ExponentialMixtureMarginalModel Functions --------- .. autoapisummary:: fluopy.distributions.hypoexponential_distribution_cdf fluopy.distributions.hypoexponential_distribution_pdf fluopy.distributions.hypoexponential_distribution_pdf_1st_order_derivative fluopy.distributions.hypoexponential_distribution_pdf_2nd_order_derivative fluopy.distributions.photoswitching_fingerprint_prepare fluopy.distributions.generate_combinations fluopy.distributions.map_to_lambdas fluopy.distributions.get_pis Module Contents --------------- .. py:function:: hypoexponential_distribution_cdf(x: float | numpy.typing.ArrayLike, *args: Any) -> float | numpy.typing.NDArray[numpy.float64] CDF of the hypoexponential distribution. :param x: Sample. :param args: Parameters (lambdas) of the hypoexponential distribution. Must be distinct and positive. :type args: float, 1-D array_like :returns: CDF of the hypoexponential distribution. :rtype: float | npt.NDArray[np.float64] .. py:function:: hypoexponential_distribution_pdf(x: float | numpy.typing.ArrayLike, *args: Any) -> float | numpy.typing.NDArray[numpy.float64] PDF of the hypoexponential distribution. :param x: Sample. :param args: Parameters (lambdas) of the hypoexponential distribution. Must be distinct and positive. :type args: float, 1-D array_like :returns: PDF of the hypoexponential distribution. :rtype: float | npt.NDArray[np.float64] .. py:function:: hypoexponential_distribution_pdf_1st_order_derivative(x: float | numpy.typing.ArrayLike, *args: Any) -> float | numpy.typing.NDArray[numpy.float64] First order derivative of the PDF of the hypoexponential distribution. :param x: Sample. :param args: Parameters (lambdas) of the hypoexponential distribution. Must be distinct and positive. :type args: float, 1-D array_like :returns: First order derivative of the PDF of the hypoexponential distribution. :rtype: float | npt.NDArray[np.float64] .. py:function:: hypoexponential_distribution_pdf_2nd_order_derivative(x: float | numpy.typing.ArrayLike, *args: Any) -> float | numpy.typing.NDArray[numpy.float64] Second order derivative of the PDF of the hypoexponential distribution. :param x: Sample. :param args: Parameters (lambdas) of the hypoexponential distribution. Must be distinct and positive. :type args: float, 1-D array_like :returns: Second order derivative of the PDF of the hypoexponential distribution. :rtype: float | npt.NDArray[np.float64] .. py:class:: Photoswitching_fingerprint_model(params: dict, weights: float | numpy.typing.ArrayLike | None = None, domain: tuple[float, float] = (0, np.inf)) Model to describe photoswitching fingerprints produced by n fluorophores where there is bias in time (e.g., increased probability of ON in the beginning). .. py:attribute:: params .. py:attribute:: weights .. py:attribute:: domain .. py:attribute:: z .. py:method:: pdf_part(call: collections.abc.Callable | None, x: float | numpy.typing.ArrayLike, i: int, normalize: bool = False) -> float | numpy.typing.NDArray[numpy.float64] PDF for the arrival times (not delta arrival times) after the i-th fluorophore has photobleached. :param call: Function to calculate the PDF (or its derivative) of the hypoexponential distribution. If None, hypoexponential_distribution_pdf is used. :param x: Sample. :param i: Index of the fluorophore that has just photobleached (0 means no photobleaching so far). :param 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 :rtype: float | npt.NDArray[np.float64] .. py:method:: pdf(x: float | numpy.typing.ArrayLike, order: int = 0) -> float | numpy.typing.NDArray[numpy.float64] PDF :param x: Sample. :param order: Order of the derivative of the PDF to be calculated. :type order: int :returns: PDF :rtype: float | npt.NDArray[np.float64] .. py:method:: cdf_part(x: float | numpy.typing.ArrayLike, i: int, normalize: bool = False) -> float | numpy.typing.NDArray[numpy.float64] CDF for the arrival times (not delta arrival times) after the i-th fluorophore has photobleached. :param x: Sample. :param i: Index of the fluorophore that has just photobleached (0 means no photobleaching so far). :param 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 :rtype: float | npt.NDArray[np.float64] .. py:method:: cdf(x: float | numpy.typing.ArrayLike, extra: bool = False) -> float | numpy.typing.NDArray[numpy.float64] CDF :param x: Sample. :param extra: If True, the CDF is not normalized to the domain. Needed for normalization of PDF and CDF. :returns: CDF :rtype: float | npt.NDArray[np.float64] .. py:method:: dpdf(x: float | numpy.typing.ArrayLike) -> float | numpy.typing.NDArray[numpy.float64] First derivative of PDF. :param x: Sample. :returns: First derivative of PDF :rtype: float | npt.NDArray[np.float64] .. py:method:: ddpdf(x: float | numpy.typing.ArrayLike) -> float | numpy.typing.NDArray[numpy.float64] Second derivative of PDF. :param x: Sample. :returns: Second derivative of PDF :rtype: float | npt.NDArray[np.float64] .. py:method:: logp(x: float | numpy.typing.ArrayLike) -> float | numpy.typing.NDArray[numpy.float64] Logarithm of the PDF. :param x: Sample. :returns: Logarithm of the PDF :rtype: float | npt.NDArray[np.float64] .. py:method:: quantile_function() -> None Quantile function. :rtype: None .. py:function:: photoswitching_fingerprint_prepare(params: dict, n: int, z: int) -> tuple[numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.float64]] Get combinations of lambdas and pis for the photoswitching fingerprint model. Needed for the PDF and CDF parts. See model derivation for details. :param params: Parameters of the underlying exponential distributions. :param n: Number of fluorophores needed to be considered. For the i-th CDF/PDF part, n = i + 1. :param 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. :rtype: tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]] .. py:function:: generate_combinations(n: int, z: int) -> numpy.typing.NDArray[numpy.int64] Generate combinations for all valid convolutions of exponential distributions. :param n: Number of fluorophores needed to be considered. For the i-th CDF/PDF part, n = i + 1. :param 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). :rtype: npt.NDArray[np.int64] .. py:function:: map_to_lambdas(combos: numpy.typing.NDArray[numpy.int_], params: dict, z: int) -> numpy.typing.NDArray[numpy.float64] Map combinations to lambdas. :param combos: All valid combinations of exponential distributions. :param params: Parameters of the underlying exponential distributions. :param 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. :rtype: npt.NDArray[np.float64] .. py:function:: get_pis(combos: numpy.typing.NDArray[numpy.int_], params: dict, z: int) -> numpy.typing.NDArray[numpy.float64] Get pis for each combination. :param combos: All valid combinations of exponential distributions. :param params: Parameters of the underlying exponential distributions. :param 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. :rtype: npt.NDArray[np.float64] .. py:class:: ExponentialMixtureModel(params: dict, domain: tuple[float, float] = (0, np.inf)) Model to describe a mixture of exponential distributions. .. py:attribute:: params .. py:attribute:: domain .. py:method:: pdf(x: float | numpy.typing.ArrayLike) -> float | numpy.typing.NDArray[numpy.float64] Probability density function of a mixture of exponential distributions. :param x: Sample. :returns: PDF of the mixture of exponential distributions. :rtype: float | npt.NDArray[np.float64] .. py:method:: cdf(x: float | numpy.typing.ArrayLike, extra: bool = False) -> float | numpy.typing.NDArray[numpy.float64] Cumulative distribution function of a mixture of exponential distributions. :param x: Sample. :param extra: ... :returns: CDF of the mixture of exponential distributions. :rtype: float | npt.NDArray[np.float64] .. py:class:: ExponentialMixtureMarginalModel(params: dict, pfa_cdf_part: collections.abc.Callable, cdf_part_index: int, truncation_up: float) 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. .. py:attribute:: pdf_grid .. py:attribute:: cdf_grid .. py:attribute:: x_grid .. py:attribute:: P_obs .. py:method:: pdf(x: float | numpy.typing.ArrayLike) -> float | numpy.typing.NDArray[numpy.float64] Probability distribution function :param x: Sample. :returns: PDF :rtype: float | npt.NDArray[np.float64] .. py:method:: cdf(x: float | numpy.typing.ArrayLike) -> float | numpy.typing.NDArray[numpy.float64] Cumulative distribution function :param x: Sample. :returns: CDF :rtype: float | npt.NDArray[np.float64]