You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix: importance sampling handling causing error when chosen method is "none" or None
- Moved importance sampling logic from `multipath_pathfinder` to `fit_pathfinder` to fix error method is "none" or None
- Update docstrings to clarify importance sampling method behavior
- Use match statement for method selection in importance_sampling
log probability values of proposal distribution, shape (L, M)
45
45
num_draws : int
46
46
number of draws to return where num_draws <= samples.shape[0]
47
-
method : str, optional
48
-
importance sampling method to use. Options are "psis" (default), "psir", "identity", "none. Pareto Smoothed Importance Sampling (psis) is recommended in many cases for more stable results than Pareto Smoothed Importance Resampling (psir). identity applies the log importance weights directly without resampling. none applies no importance sampling weights and returns the samples as is of size num_draws_per_path * num_paths.
47
+
method : str, None, optional
48
+
Method to apply sampling based on log importance weights (logP - logQ).
"identity" : Applies log importance weights directly without resampling.
55
+
None : No importance sampling weights. Returns raw samples of size (num_paths, num_draws_per_path, N) where N is number of model parameters. Other methods return samples of size (num_draws, N).
49
56
random_seed : int | None
50
57
51
58
Returns
@@ -71,11 +78,11 @@ def importance_sampling(
71
78
warnings= []
72
79
num_paths, _, N=samples.shape
73
80
74
-
ifmethod=="none":
81
+
ifmethodisNone:
75
82
warnings.append(
76
83
"Importance sampling is disabled. The samples are returned as is which may include samples from failed paths with non-finite logP or logQ values. It is recommended to use importance_sampling='psis' for better stability."
Amount of jitter to apply to initial points (default is 2.0). Note that Pathfinder may be highly sensitive to the jitter value. It is recommended to increase num_paths when increasing the jitter value.
1461
1461
epsilon: float
1462
1462
value used to filter out large changes in the direction of the update gradient at each iteration l in L. Iteration l is only accepted if delta_theta[l] * delta_grad[l] > epsilon * L2_norm(delta_grad[l]) for each l in L. (default is 1e-8).
1463
-
importance_sampling : str, optional
1464
-
importance sampling method to use which applies sampling based on the log importance weights equal to logP - logQ. Options are "psis" (default), "psir", "identity", "none". Pareto Smoothed Importance Sampling (psis) is recommended in many cases for more stable results than Pareto Smoothed Importance Resampling (psir). identity applies the log importance weights directly without resampling. none applies no importance sampling weights and returns the samples as is of size (num_paths, num_draws_per_path, N) where N is the number of model parameters, otherwise sample size is (num_draws, N).
1463
+
importance_sampling : str, None, optional
1464
+
Method to apply sampling based on log importance weights (logP - logQ).
"identity" : Applies log importance weights directly without resampling.
1470
+
None : No importance sampling weights. Returns raw samples of size (num_paths, num_draws_per_path, N) where N is number of model parameters. Other methods return samples of size (num_draws, N).
1465
1471
progressbar : bool, optional
1466
1472
Whether to display a progress bar (default is False). Setting this to True will likely increase the computation time.
1467
1473
random_seed : RandomSeed, optional
@@ -1483,12 +1489,6 @@ def multipath_pathfinder(
1483
1489
The result containing samples and other information from the Multi-Path Pathfinder algorithm.
Amount of jitter to apply to initial points (default is 2.0). Note that Pathfinder may be highly sensitive to the jitter value. It is recommended to increase num_paths when increasing the jitter value.
1663
1663
epsilon: float
1664
1664
value used to filter out large changes in the direction of the update gradient at each iteration l in L. Iteration l is only accepted if delta_theta[l] * delta_grad[l] > epsilon * L2_norm(delta_grad[l]) for each l in L. (default is 1e-8).
1665
-
importance_sampling : str, optional
1666
-
importance sampling method to use which applies sampling based on the log importance weights equal to logP - logQ. Options are "psis" (default), "psir", "identity", "none". Pareto Smoothed Importance Sampling (psis) is recommended in many cases for more stable results than Pareto Smoothed Importance Resampling (psir). identity applies the log importance weights directly without resampling. none applies no importance sampling weights and returns the samples as is of size (num_paths, num_draws_per_path, N) where N is the number of model parameters, otherwise sample size is (num_draws, N).
1665
+
importance_sampling : str, None, optional
1666
+
Method to apply sampling based on log importance weights (logP - logQ).
"identity" : Applies log importance weights directly without resampling.
1673
+
None : No importance sampling weights. Returns raw samples of size (num_paths, num_draws_per_path, N) where N is number of model parameters. Other methods return samples of size (num_draws, N).
1667
1674
progressbar : bool, optional
1668
1675
Whether to display a progress bar (default is True). Setting this to False will likely reduce the computation time.
0 commit comments