simoa package¶
Submodules¶
simoa.mser module¶
-
exception
simoa.mser.
MSERException
[source]¶ Bases:
BaseException
-
exception
simoa.mser.
MSERInsufficientDataError
[source]¶ Bases:
simoa.mser.MSERException
,RuntimeError
-
class
simoa.mser.
MSERReturnValue
(mean, ci, env)¶ Bases:
tuple
-
__getnewargs__
()¶ Return self as a plain tuple. Used by copy and pickle.
-
__getstate__
()¶ Exclude the OrderedDict from pickling
-
static
__new__
(_cls, mean, ci, env)¶ Create new instance of MSERReturnValue(mean, ci, env)
-
__repr__
()¶ Return a nicely formatted representation string
-
ci
¶ Alias for field number 1
-
env
¶ Alias for field number 2
-
mean
¶ Alias for field number 0
-
-
simoa.mser.
compute_mser5_interval
(data, confidence_level=0.68268949213708585, continue_insufficient_data=False)[source]¶ Estimate the steady-state mean and the interval by the MSER-5 method
Notes
“MSER-5 (Franklin and White 2008) is a modification of the Marginal Confidence Rule (MCR) or the Marginal Standard Error Rule (MSER) proposed by White (1997).” [1]_ “MSER-5 is a sequential procedure that uses the method of nonoverlapping batch means (NBM) to deliver not only a data-truncation point (i.e., end of the “warm-up period”) but also point and CI estimators [...] computed from the truncated (“warmed-up”) sequence of batch means.” [1]_
References
[1] Mokashi, A. C. et al. Performance comparison of MSER-5 and N-Skart on the simulation start-up problem. In Proceedings of the Winter Simulation Conference, 971-982 (2010). http://www.ise.ncsu.edu/jwilson/files/mokashi10wsc.pdf [2] Franklin, W. W. & White, K. P. Stationarity tests and MSER-5: Exploring the intuition behind mean-squared-error-reduction in detecting and correcting initialization bias. In Winter Simulation Conference, 541-546 (2008). http://www.informs-sim.org/wsc08papers/064.pdf [3] White, K. P. An effective truncation heuristic for bias reduction in simulation output. Simulation 69, 323-334 (1997). http://dx.doi.org/10.1177/003754979706900601
simoa.nskart module¶
-
exception
simoa.nskart.
NSkartException
[source]¶ Bases:
BaseException
-
class
simoa.nskart.
NSkartReturnValue
(mean, ci, env)¶ Bases:
tuple
-
__getnewargs__
()¶ Return self as a plain tuple. Used by copy and pickle.
-
__getstate__
()¶ Exclude the OrderedDict from pickling
-
static
__new__
(_cls, mean, ci, env)¶ Create new instance of NSkartReturnValue(mean, ci, env)
-
__repr__
()¶ Return a nicely formatted representation string
-
ci
¶ Alias for field number 1
-
env
¶ Alias for field number 2
-
mean
¶ Alias for field number 0
-
-
simoa.nskart.
ONE_SIGMA
= 0.68268949213708585¶ Minimum number of data points
-
simoa.nskart.
compute_nskart_interval
(data, confidence_level=0.68268949213708585, continue_insufficient_data=False)[source]¶ Compute the confidence interval for the steady-state mean
Implements the N-Skart algorithm, “a nonsequential procedure designed to deliver a confidence interval for the steady-state mean of a simulation output process when the user supplies a single simulation-generated time series of arbitrary size and specifies the required coverage probability for a confidence interval based on that data set.”
Notes
“N-Skart is a variant of the method of batch means that exploits separate adjustments to the half-length of the CI so as to account for the effects on the distribution of the underlying Student’s t-statistic that arise from skewness (nonnormality) and autocorrelation of the batch means. If the sample size is sufficiently large, then N-Skart delivers not only a CI but also a point estimator for the steady-state mean that is approximately free of initialization bias.”
References
[1] Tafazzoli, A.; Steiger, N.M.; Wilson, J.R., “N-Skart: A Nonsequential Skewness- and Autoregression-Adjusted Batch-Means Procedure for Simulation Analysis,” Automatic Control, IEEE Transactions on , vol.56, no.2, pp.254,264, 2011 doi: 10.1109/TAC.2010.2052137
simoa.stats module¶
Copyright 2015 The pysimoa Developers
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
simoa.stats.
online_variance
(row_a, row_b)[source]¶ Combine the sample mean and variance of two samples
This is a function ready for use for reduce. It is commutative and associative.
Parameters: row_b (row_a,) – Tuple-like variables with first item being the number of data points in that sample, the second item being the mean of that sample, and the third item being the sum of squared differences of the data points to the mean in that sample. Returns: - ret (tuple) –
(n_ab, mean_ab, m2_ab)
- n_ab – number of data points in the combined sample
- mean_ab – mean of the combined sample
- m2_ab –
sum of squared difference to the mean.
To get the variance, divide by
n_ab - 1
.
Notes
\[n_{ab} = n_a + n_b \bar{x}_ab = \frac{n_a \bar{x}_a + n_b \bar{x}_b}{n_{ab}} S_{ab} = S_a + S_b + \frac{n_a n_b}{n_{ab}} (\bar{x}_b - \bar{x}_a)^2\]References
https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
Chan, Tony F., Gene H. Golub, and Randall J. LeVeque. “Algorithms for computing the sample variance: Analysis and recommendations.” The American Statistician 37.3 (1983): 242-247. http://www.jstor.org/stable/2683386
Chan, Tony F., Gene H. Golub, and Randall J. LeVeque. “Updating formulae and a pairwise algorithm for computing sample variances.” COMPSTAT 1982 5th Symposium held at Toulouse 1982. Physica-Verlag HD, 1982. http://i.stanford.edu/pub/cstr/reports/cs/tr/79/773/CS-TR-79-773.pdf
- ret (tuple) –
-
simoa.stats.
von_neumann_ratio_test
(data, alpha, verbose=False)[source]¶ Test a series of observations for independence (lack of autocorrelation)
The von-Neumann ratio test is a statistical test designed for testing the independence of subsequent observations. The null hypothesis is that the data are independent and normally distributed.
- alpha: float
- Significance level. This is the probability threshold below which the null hypothesis will be rejected.
Given a series \(x_i\) of \(n\) data points, the von-Neumann test statistic is [1]_ [6]_
\[v =\]- rac{sum_{i=1}^{n-1} (x_{i+1} - x_i)^2}{sum_{i=1}^n (x_i -
- ar{x})^2
Under the null hypothesis, the mean \(ar{v} = 2\) and the variance :math:`sigma^2_v =
rac{4 (n - 2)}{(n-1)(n+1)}` [3]_.
[1] Von Neumann, J. (1941). Distribution of the ratio of the mean square successive difference to the variance. The Annals of Mathematical Statistics, 12(4), 367-395. [2] The Mean Square Successive Difference J. von Neumann, R. H. Kent, H. R. Bellinson and B. I. Hart The Annals of Mathematical Statistics Vol. 12, No. 2 (Jun., 1941) , pp. 153-162 http://www.jstor.org/stable/2235765 [3] Moments of the Ratio of the Mean Square Successive Difference to the Mean Square Difference in Samples From a Normal Universe J. D. Williams The Annals of Mathematical Statistics Vol. 12, No. 2 (Jun., 1941) , pp. 239-241 http://www.jstor.org/stable/2235775 [4] Madansky, Albert, Testing for Independence of Observations, In: Prescriptions for Working Statisticians Springer New York 10.1007/978-1-4612-3794-5_4 http://dx.doi.org/10.1007/978-1-4612-3794-5_4