Skip to content

Commit dba28fc

Browse files
committed
Distribution: vectorize variance
This makes normalization much faster.
1 parent 68cbfdb commit dba28fc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Orange/statistics/distribution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def mean(self):
302302

303303
def variance(self):
304304
mean = self.mean()
305-
return sum(((x - mean) ** 2) * w for x, w in zip(self[0], self[1])) / sum(self[1])
305+
return np.dot((self[0] - mean) ** 2, self[1]) / np.sum(self[1])
306306

307307
def standard_deviation(self):
308308
return np.sqrt(self.variance())

0 commit comments

Comments
 (0)