@@ -64,12 +64,6 @@ def best_fit_distribution(data: List[float], logger: Optional[Logger] = None) ->
6464
6565
6666 normalized = (data - np .min (data )) / (np .max (data ) - np .min (data )) if not np .min (data ) == np .max (data ) else np .min (data )
67- # Old broken code
68- # y, x = np.histogram(normalized, bins=bins)
69- # if np.max(y) - np.min(y) > 0:
70- # y = (y - np.min(y)) / (np.max(y) - np.min(y))
71- # else:
72- # y = np.zeros(len(y))
7367 # Compare a probability-density histogram against the fitted PDF.
7468 y , bin_edges = np .histogram (normalized , bins = bins , density = True )
7569 x = (bin_edges [:- 1 ] + bin_edges [1 :]) / 2
@@ -90,14 +84,10 @@ def best_fit_distribution(data: List[float], logger: Optional[Logger] = None) ->
9084 with warnings .catch_warnings ():
9185 try :
9286 distribution = getattr (scipy .stats , dist_name )
93- # params = distribution.fit(y)
94- # below: correct call to fit!
9587 params = distribution .fit (normalized )
9688
9789 # calculate fitted PDF and error with fit in distribution
9890 pdf = distribution .pdf (x , * params [:- 2 ], loc = params [- 2 ], scale = params [- 1 ])
99- # sse = np.sum(np.power(y - pdf[0:bins], 2.0))
100- # below: corrected code
10191 sse = np .sum (np .power (y - pdf , 2.0 ))
10292
10393 # identify if this distribution is better
0 commit comments