Skip to content

Commit

Permalink
improve x_val (#440)
Browse files Browse the repository at this point in the history
* improve x_val, find_ppf

* improve x_val
  • Loading branch information
aloctavodia authored May 18, 2024
1 parent 34c4709 commit 84e4a40
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions preliz/distributions/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,11 @@ def xvals(self, support, n_points=1000):
n_points : int
Number of values to return.
"""
half_n_points = int(n_points / 2)

if isinstance(support, tuple):
return self.ppf(np.linspace(*self.cdf(support), n_points))
even = np.linspace(*support, n_points)
uneven = self.ppf(np.linspace(*self.cdf(support), n_points))
else:
lower_ep, upper_ep = self.support

Expand All @@ -611,11 +614,10 @@ def xvals(self, support, n_points=1000):
if not np.isfinite(upper_ep) or support == "restricted":
upper_ep = 0.9999

half_n_points = int(n_points / 2)
even = np.linspace(*self.ppf([lower_ep, upper_ep]), half_n_points)
uneven = self.ppf(np.linspace(lower_ep, upper_ep, half_n_points))

return np.sort(np.concatenate([even, uneven]))
return np.sort(np.concatenate([even, uneven]))

def _fit_mle(self, sample, **kwargs):
"""
Expand Down

0 comments on commit 84e4a40

Please sign in to comment.