Skip to content

Commit c2edc41

Browse files
[main-major-20] (PR #86)
Merge pull request #86 from syedalimohsinbukhari/log-correction
2 parents b4e6a7a + b7a1971 commit c2edc41

File tree

82 files changed

+1688
-1400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1688
-1400
lines changed

benchmarks/CDF_multifit_df.csv

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

benchmarks/CDF_multifit_variable_df.csv

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

benchmarks/CDF_scipy_df.csv

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

benchmarks/CDF_scipy_variable_df.csv

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

benchmarks/PDF_multifit_df.csv

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

benchmarks/PDF_multifit_variable_df.csv

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

benchmarks/PDF_scipy_df.csv

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

benchmarks/PDF_scipy_variable_df.csv

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

benchmarks/accuracy.ipynb

Lines changed: 589 additions & 85 deletions
Large diffs are not rendered by default.

benchmarks/functions.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import numpy as np
77
import pandas as pd
88
import seaborn as sns
9+
import statsmodels.api as sm
910
from matplotlib import pyplot as plt
1011
from matplotlib.colors import TwoSlopeNorm
1112
from matplotlib.ticker import FixedLocator
@@ -29,8 +30,9 @@ def compare_accuracy(x, custom_dist, scipy_dist):
2930
pdf_scipy = scipy_dist.pdf(x)
3031
cdf_scipy = scipy_dist.cdf(x)
3132

32-
pdf_abs_diff = np.abs(pdf_custom - pdf_scipy) + EPSILON
33-
cdf_abs_diff = np.abs(cdf_custom - cdf_scipy) + EPSILON
33+
with np.errstate(invalid='ignore'):
34+
pdf_abs_diff = np.nan_to_num(np.abs(pdf_custom - pdf_scipy), False, 0) + EPSILON
35+
cdf_abs_diff = np.nan_to_num(np.abs(cdf_custom - cdf_scipy), False, 0) + EPSILON
3436

3537
class_name = custom_dist.__class__.__name__
3638
cond = class_name != 'SkewNormalDistribution'
@@ -40,8 +42,11 @@ def compare_accuracy(x, custom_dist, scipy_dist):
4042
logcdf_custom = custom_dist.logcdf(x)
4143
logpdf_scipy = scipy_dist.logpdf(x)
4244
logcdf_scipy = scipy_dist.logcdf(x)
43-
logpdf_abs_diff = np.abs(logpdf_custom - logpdf_scipy) + EPSILON
44-
logcdf_abs_diff = np.abs(logcdf_custom - logcdf_scipy) + EPSILON
45+
with np.errstate(invalid='ignore'):
46+
logpdf_abs_diff = np.nan_to_num(np.abs(logpdf_custom - logpdf_scipy),
47+
False, 0) + EPSILON
48+
logcdf_abs_diff = np.nan_to_num(np.abs(logcdf_custom - logcdf_scipy),
49+
False, 0) + EPSILON
4550

4651
return {"pdf_abs_diff": pdf_abs_diff,
4752
"log_pdf_abs_diff": logpdf_abs_diff if cond else None,
@@ -165,8 +170,6 @@ def plot_speed_and_ratios(n_points_list, times_class, times_scipy, title_suffix,
165170
plt.legend()
166171
plt.grid(True)
167172

168-
import statsmodels.api as sm
169-
170173
lowess_results = sm.nonparametric.lowess(ratio_means, n_points_list, frac=0.3)
171174
x_smooth, y_smooth = lowess_results[:, 0], lowess_results[:, 1]
172175

0 commit comments

Comments
 (0)