diff --git a/levy/__init__.py b/levy/__init__.py index f70f15b..5311c4d 100644 --- a/levy/__init__.py +++ b/levy/__init__.py @@ -40,7 +40,7 @@ Parameters.convert to transform the parameters from one parametrization to another. The module uses internally parametrization 0. -- pylevy does not support alpha values less than 0.5. +- pylevy does not support alpha values lower than 0.5. """ import sys @@ -305,11 +305,14 @@ def _calculate_levy(x, alpha, beta, cdf=False): if alpha == 1: li = 1e-10 + # These functions need a correction, since the distribution is displaced, probably get rid of "-u" at the end def func_cos(u): - return np.exp(-u) * np.cos(-beta * 2 / np.pi * (u * np.log(u) - u)) + # return np.exp(-u) * np.cos(-beta * 2 / np.pi * (u * np.log(u) - u)) + return np.exp(-u) * np.cos(-beta * 2 / np.pi * u * np.log(u)) def func_sin(u): - return np.exp(-u) * np.sin(-beta * 2 / np.pi * (u * np.log(u) - u)) + # return np.exp(-u) * np.sin(-beta * 2 / np.pi * (u * np.log(u) - u)) + return np.exp(-u) * np.sin(-beta * 2 / np.pi * u * np.log(u)) else: li = 0 @@ -342,7 +345,9 @@ def _approximate(x, alpha, beta, cdf=False): values[mask] *= (1.0 + beta) values[~mask] *= (1.0 - beta) if cdf: - return 1.0 - values * x + values[mask] = 1.0 - values[mask] * x[mask] + values[~mask] = values[~mask] * (-x[~mask]) + return values else: return values * alpha @@ -603,7 +608,7 @@ def random(alpha, beta, mu=0.0, sigma=1.0, shape=()): return np.random.standard_normal(shape) * np.sqrt(2.0) # Fails for alpha exactly equal to 1.0 - # but works fine for alpha infinitesimally greater or less than 1.0 + # but works fine for alpha infinitesimally greater or lower than 1.0 radius = 1e-15 # <<< this number is *very* small if np.absolute(alpha - 1.0) < radius: # So doing this will make almost exactly no difference at all diff --git a/levy/cdf.npz b/levy/cdf.npz index a1c1f22..ec72fbe 100644 Binary files a/levy/cdf.npz and b/levy/cdf.npz differ diff --git a/levy/lower_limit.npz b/levy/lower_limit.npz index 9254d5f..ccf1101 100644 Binary files a/levy/lower_limit.npz and b/levy/lower_limit.npz differ diff --git a/levy/pdf.npz b/levy/pdf.npz index 8feef59..c1c6b57 100644 Binary files a/levy/pdf.npz and b/levy/pdf.npz differ diff --git a/levy/upper_limit.npz b/levy/upper_limit.npz index b85a91c..4fc7e50 100644 Binary files a/levy/upper_limit.npz and b/levy/upper_limit.npz differ