MCPcopy Index your code
hub / github.com/python/cpython / __add__

Method __add__

Lib/statistics.py:1371–1383  ·  view source on GitHub ↗

Add a constant or another NormalDist instance. If *other* is a constant, translate mu by the constant, leaving sigma unchanged. If *other* is a NormalDist, add both the means and the variances. Mathematically, this works only if the two distributions are ind

(x1, x2)

Source from the content-addressed store, hash-verified

1369 return self._sigma * self._sigma
1370
1371 def __add__(x1, x2):
1372 """Add a constant or another NormalDist instance.
1373
1374 If *other* is a constant, translate mu by the constant,
1375 leaving sigma unchanged.
1376
1377 If *other* is a NormalDist, add both the means and the variances.
1378 Mathematically, this works only if the two distributions are
1379 independent or if they are jointly normally distributed.
1380 """
1381 if isinstance(x2, NormalDist):
1382 return NormalDist(x1._mu + x2._mu, hypot(x1._sigma, x2._sigma))
1383 return NormalDist(x1._mu + x2, x1._sigma)
1384
1385 def __sub__(x1, x2):
1386 """Subtract a constant or another NormalDist instance.

Callers

nothing calls this directly

Calls 1

NormalDistClass · 0.85

Tested by

no test coverage detected