mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Added mean and standard deviation calculation to property decorators
This commit is contained in:
parent
31af473331
commit
501cc3e691
1 changed files with 15 additions and 3 deletions
|
|
@ -269,10 +269,16 @@ class Tally(object):
|
|||
|
||||
@property
|
||||
def mean(self):
|
||||
# Compute the mean if needed
|
||||
if self._mean is None:
|
||||
self.compute_mean()
|
||||
return self._mean
|
||||
|
||||
@property
|
||||
def std_dev(self):
|
||||
# Compute the standard deviation if needed
|
||||
if self._std_dev is None:
|
||||
self.compute_std_dev()
|
||||
return self._std_dev
|
||||
|
||||
@estimator.setter
|
||||
|
|
@ -439,8 +445,14 @@ class Tally(object):
|
|||
|
||||
self._nuclides.remove(nuclide)
|
||||
|
||||
def compute_mean(self):
|
||||
"""Compute the sample mean for each bin in the tally"""
|
||||
|
||||
# Calculate sample mean
|
||||
self._mean = self.sum / self.num_realizations
|
||||
|
||||
def compute_std_dev(self, t_value=1.0):
|
||||
"""Compute the sample mean and standard deviation for each bin in the tally
|
||||
"""Compute the sample standard deviation for each bin in the tally
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
|
@ -450,8 +462,8 @@ class Tally(object):
|
|||
|
||||
"""
|
||||
|
||||
# Calculate sample mean and standard deviation
|
||||
self._mean = self.sum / self.num_realizations
|
||||
# Calculate sample standard deviation
|
||||
self.compute_mean()
|
||||
self._std_dev = np.sqrt((self.sum_sq / self.num_realizations -
|
||||
self.mean**2) / (self.num_realizations - 1))
|
||||
self._std_dev *= t_value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue