mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 05:05:30 -04:00
Adding simple test for normal distribution
This commit is contained in:
parent
8070ccaf52
commit
2f22474aea
1 changed files with 14 additions and 0 deletions
|
|
@ -65,6 +65,7 @@ def test_uniform():
|
|||
assert t.p == [1/(b-a), 1/(b-a)]
|
||||
assert t.interpolation == 'histogram'
|
||||
|
||||
|
||||
def test_powerlaw():
|
||||
a, b, n = 10.0, 20.0, 2.0
|
||||
d = openmc.stats.PowerLaw(a, b, n)
|
||||
|
|
@ -76,6 +77,7 @@ def test_powerlaw():
|
|||
assert d.n == n
|
||||
assert len(d) == 3
|
||||
|
||||
|
||||
def test_maxwell():
|
||||
theta = 1.2895e6
|
||||
d = openmc.stats.Maxwell(theta)
|
||||
|
|
@ -264,6 +266,18 @@ def test_normal():
|
|||
assert d.std_dev == pytest.approx(std_dev)
|
||||
assert len(d) == 2
|
||||
|
||||
# sample normal distribution
|
||||
n_samples = 10000
|
||||
samples = d.sample(n_samples, seed=100)
|
||||
samples = np.abs(samples - mean)
|
||||
within_1_sigma = np.count_nonzero(samples < std_dev)
|
||||
assert within_1_sigma / n_samples >= 0.68
|
||||
within_2_sigma = np.count_nonzero(samples < 2*std_dev)
|
||||
assert within_2_sigma / n_samples >= 0.95
|
||||
within_3_sigma = np.count_nonzero(samples < 3*std_dev)
|
||||
assert within_3_sigma / n_samples >= 0.99
|
||||
|
||||
|
||||
def test_muir():
|
||||
mean = 10.0
|
||||
mass = 5.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue