Package InversionTest :: Module MonteCarloSampler :: Class MCHypothesisTest
[hide private]
[frames] | no frames]

Class MCHypothesisTest

         object --+    
                  |    
MonteCarloEstimator --+
                      |
                     MCHypothesisTest
Known Subclasses:

Monte Carlo Bernoulli Hypothesis Test

Instance Methods [hide private]
 
__init__(self, sample1, sample2, testStatistic, alternative='two.sided', maxSamples=10000)
Initialize the estimator
 
_finalizeEstimate(self)
Finalize the estimate, which is the # positive samples divided by total samples
list of object
_sampleFunction(self)
Sample function for the estimator.
 
_startEstimate(self)
Start the Monte Carlo estimate
 
_updateSupport(self, statistic)
Update the count of samples where the alternate hypothesis was confirmed
callable
getSampleFunction(self)
Return the sample function, which generates random samples
callable
getStatisticFunction(self)
Get the statistic function for the estimator.

Inherited from MonteCarloEstimator: addSamples, getEstimate, getNumSamples, updateEstimate

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  VERBOSE = True
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, sample1, sample2, testStatistic, alternative='two.sided', maxSamples=10000)
(Constructor)

 

Initialize the estimator

Parameters:
  • sample1 (list of object) - First sample of data points
  • sample2 (list of object) - Second sample of data points
  • testStatistic (callable) - Statistic function to run on each sample, in the form f(sample): return statistic
  • alternative (str) - Alternate hypothesis, from the set GREATER_THAN_HYPOTHESIS, LESS_THAN_HYPOTHESIS, TWO_SIDED_HYPOTHESIS
  • maxSamples (int) - Maximum number of samples to run for an estimate
Overrides: object.__init__

_finalizeEstimate(self)

 

Finalize the estimate, which is the # positive samples divided by total samples

Overrides: MonteCarloEstimator._finalizeEstimate

_sampleFunction(self)

 

Sample function for the estimator. This shuffles the combined sample of sample1 + sample2, returning a random permutation.

Returns: list of object
Random permutation of the combined sample set

_startEstimate(self)

 

Start the Monte Carlo estimate

Overrides: MonteCarloEstimator._startEstimate

_updateSupport(self, statistic)

 

Update the count of samples where the alternate hypothesis was confirmed

Parameters:
  • statistic (int) - If sample confirms alternate value is 1, else value is 0
Overrides: MonteCarloEstimator._updateSupport

getSampleFunction(self)

 

Return the sample function, which generates random samples

Returns: callable
Sample generating function, in the form f(): return sample
Overrides: MonteCarloEstimator.getSampleFunction

getStatisticFunction(self)

 

Get the statistic function for the estimator. This function calculates an indicator variable based on a sample as generated by getSampleFunction.

Returns: callable
Statistic function in form f(sample): return bool
Overrides: MonteCarloEstimator.getStatisticFunction