From 61068321d3b29fab90d14469b89d2dc68ca90e61 Mon Sep 17 00:00:00 2001 From: Jonathan-Lindbloom Date: Sat, 9 Jul 2022 09:45:28 -0600 Subject: [PATCH 1/9] updated docstring for find_constrained_prior --- pymc/func_utils.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pymc/func_utils.py b/pymc/func_utils.py index 74f55b7e16..a3f57edb63 100644 --- a/pymc/func_utils.py +++ b/pymc/func_utils.py @@ -36,7 +36,7 @@ def find_constrained_prior( ) -> Dict[str, float]: """ Find optimal parameters to get `mass` % of probability - of `pm_dist` between `lower` and `upper`. + of a `pm_dist` between `lower` and `upper`. Note: only works for one- and two-parameter distributions, as there are exactly two constraints. Fix some combination of parameters if you want to use it on >=3-parameter distributions. @@ -50,24 +50,25 @@ def find_constrained_prior( Lower bound to get `mass` % of probability of `pm_dist`. upper : float Upper bound to get `mass` % of probability of `pm_dist`. - init_guess: Dict[str, float] + init_guess : str or float Initial guess for ``scipy.optimize.least_squares`` to find the optimal parameters of `pm_dist` fitting the interval constraint. Must be a dictionary with the name of the PyMC distribution's parameter as keys and the initial guess as values. - mass: float, default to 0.95 + mass : float, default to 0.95 Share of the probability mass we want between ``lower`` and ``upper``. Defaults to 95%. - fixed_params: Dict[str, float], Optional, default None + fixed_params : str or float, optional, default None Only used when `pm_dist` has at least three parameters. Dictionary of fixed parameters, so that there are only 2 to optimize. - For instance, for a StudenT, you fix nu to a constant and get the optimized + For instance, for a StudentT, you fix nu to a constant and get the optimized mu and sigma. Returns ------- - The optimized distribution parameters as a dictionary with the parameters' - name as key and the optimized value as value. + opt_params: dict + The optimized distribution parameters as a dictionary with the parameters' and + name as key and the optimized value as value. Examples -------- From 871395464a2826e980a6255dcacab58ed44b073d Mon Sep 17 00:00:00 2001 From: Jonathan Lindbloom <35314883+jlindbloom@users.noreply.github.com> Date: Sun, 10 Jul 2022 16:31:00 -0600 Subject: [PATCH 2/9] Update pymc/func_utils.py Co-authored-by: Michael Osthege --- pymc/func_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pymc/func_utils.py b/pymc/func_utils.py index a3f57edb63..e1e484af3e 100644 --- a/pymc/func_utils.py +++ b/pymc/func_utils.py @@ -67,8 +67,9 @@ def find_constrained_prior( Returns ------- opt_params: dict - The optimized distribution parameters as a dictionary with the parameters' and - name as key and the optimized value as value. + The optimized distribution parameters as a dictionary. + Dictionary keys are the parameter names and + dictionary values are the optimized parameter values. Examples -------- From 887db6367d1e41508df75cce7f6bd84da401f1bd Mon Sep 17 00:00:00 2001 From: Jonathan Lindbloom <35314883+jlindbloom@users.noreply.github.com> Date: Mon, 11 Jul 2022 13:13:26 -0600 Subject: [PATCH 3/9] Update pymc/func_utils.py Co-authored-by: Oriol Abril-Pla --- pymc/func_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pymc/func_utils.py b/pymc/func_utils.py index e1e484af3e..b8676bca5c 100644 --- a/pymc/func_utils.py +++ b/pymc/func_utils.py @@ -36,7 +36,8 @@ def find_constrained_prior( ) -> Dict[str, float]: """ Find optimal parameters to get `mass` % of probability - of a `pm_dist` between `lower` and `upper`. + of a :ref:`distribution ` between `lower` and `upper`. + Note: only works for one- and two-parameter distributions, as there are exactly two constraints. Fix some combination of parameters if you want to use it on >=3-parameter distributions. From aab74f5af60a9aa0a3d8a3df9d649ad385aa5da0 Mon Sep 17 00:00:00 2001 From: Jonathan Lindbloom <35314883+jlindbloom@users.noreply.github.com> Date: Mon, 11 Jul 2022 13:13:36 -0600 Subject: [PATCH 4/9] Update pymc/func_utils.py Co-authored-by: Oriol Abril-Pla --- pymc/func_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymc/func_utils.py b/pymc/func_utils.py index b8676bca5c..3e92a96df9 100644 --- a/pymc/func_utils.py +++ b/pymc/func_utils.py @@ -51,7 +51,7 @@ def find_constrained_prior( Lower bound to get `mass` % of probability of `pm_dist`. upper : float Upper bound to get `mass` % of probability of `pm_dist`. - init_guess : str or float + init_guess : dict of {str : float} Initial guess for ``scipy.optimize.least_squares`` to find the optimal parameters of `pm_dist` fitting the interval constraint. Must be a dictionary with the name of the PyMC distribution's From 19e3d68e4b0aa00c5736b5b668467f3ad70e67bc Mon Sep 17 00:00:00 2001 From: Jonathan Lindbloom <35314883+jlindbloom@users.noreply.github.com> Date: Mon, 11 Jul 2022 13:13:50 -0600 Subject: [PATCH 5/9] Update pymc/func_utils.py Co-authored-by: Oriol Abril-Pla --- pymc/func_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymc/func_utils.py b/pymc/func_utils.py index 3e92a96df9..88bce9ec1a 100644 --- a/pymc/func_utils.py +++ b/pymc/func_utils.py @@ -56,7 +56,7 @@ def find_constrained_prior( optimal parameters of `pm_dist` fitting the interval constraint. Must be a dictionary with the name of the PyMC distribution's parameter as keys and the initial guess as values. - mass : float, default to 0.95 + mass : float, default 0.95 Share of the probability mass we want between ``lower`` and ``upper``. Defaults to 95%. fixed_params : str or float, optional, default None From e8d56e0460f007ca636116ea78e7c0dc7c0a7f22 Mon Sep 17 00:00:00 2001 From: Jonathan Lindbloom <35314883+jlindbloom@users.noreply.github.com> Date: Mon, 11 Jul 2022 13:13:59 -0600 Subject: [PATCH 6/9] Update pymc/func_utils.py Co-authored-by: Oriol Abril-Pla --- pymc/func_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymc/func_utils.py b/pymc/func_utils.py index 88bce9ec1a..e22b356758 100644 --- a/pymc/func_utils.py +++ b/pymc/func_utils.py @@ -67,7 +67,7 @@ def find_constrained_prior( Returns ------- - opt_params: dict + opt_params : dict The optimized distribution parameters as a dictionary. Dictionary keys are the parameter names and dictionary values are the optimized parameter values. From 48e3f05435809fcf5971001887eb14430521f036 Mon Sep 17 00:00:00 2001 From: Jonathan-Lindbloom Date: Mon, 11 Jul 2022 13:28:55 -0600 Subject: [PATCH 7/9] changed pm.Distribution to Distribution --- pymc/func_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymc/func_utils.py b/pymc/func_utils.py index e22b356758..cffeadfdd5 100644 --- a/pymc/func_utils.py +++ b/pymc/func_utils.py @@ -44,7 +44,7 @@ def find_constrained_prior( Parameters ---------- - distribution : pm.Distribution + distribution : Distribution PyMC distribution you want to set a prior on. Needs to have a ``logcdf`` method implemented in PyMC. lower : float From 8b36764f0ba5100e8796de6d2a7462ec1dc63775 Mon Sep 17 00:00:00 2001 From: Jonathan Lindbloom <35314883+jlindbloom@users.noreply.github.com> Date: Mon, 11 Jul 2022 16:45:25 -0600 Subject: [PATCH 8/9] Update pymc/func_utils.py --- pymc/func_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymc/func_utils.py b/pymc/func_utils.py index cffeadfdd5..29b86a9e22 100644 --- a/pymc/func_utils.py +++ b/pymc/func_utils.py @@ -51,7 +51,7 @@ def find_constrained_prior( Lower bound to get `mass` % of probability of `pm_dist`. upper : float Upper bound to get `mass` % of probability of `pm_dist`. - init_guess : dict of {str : float} + init_guess : dict of {str : float} Initial guess for ``scipy.optimize.least_squares`` to find the optimal parameters of `pm_dist` fitting the interval constraint. Must be a dictionary with the name of the PyMC distribution's From 32a72f071c4b1d6ddb0744c6ffef0dd818b0d703 Mon Sep 17 00:00:00 2001 From: Osvaldo A Martin Date: Wed, 13 Jul 2022 12:49:11 -0300 Subject: [PATCH 9/9] remove white space --- pymc/func_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymc/func_utils.py b/pymc/func_utils.py index 29b86a9e22..29fb59831e 100644 --- a/pymc/func_utils.py +++ b/pymc/func_utils.py @@ -37,7 +37,7 @@ def find_constrained_prior( """ Find optimal parameters to get `mass` % of probability of a :ref:`distribution ` between `lower` and `upper`. - + Note: only works for one- and two-parameter distributions, as there are exactly two constraints. Fix some combination of parameters if you want to use it on >=3-parameter distributions.