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

Class MonteCarloEstimator

object --+
         |
        MonteCarloEstimator
Known Subclasses:

A Monte Carlo Estimator

Instance Methods [hide private]
 
__init__(self, maxSamples=10000)
Initialize the estimator
 
_finalizeEstimate(self)
Finalize the estimate
 
_startEstimate(self)
Start the Monte Carlo estimate
 
_updateSupport(self, statistic)
Update support based on the latest statistic value
 
addSamples(self, n, finalize=True)
Add a maximum of n samples to the estimate
object
getEstimate(self, update=False)
Get the value of the Monte Carlo estimate.
int
getNumSamples(self)
Return the number of samples used in the estimate so far
callable
getSampleFunction(self)
Return the sample function, which generates random samples
callable
getStatisticFunction(self)
Get the function that calculates a statistic from a sample
 
updateEstimate(self)
Calculate and store the Monte Carlo estimate

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, maxSamples=10000)
(Constructor)

 

Initialize the estimator

Parameters:
  • maxSamples (int) - Maximum number of samples to run for an estimate
Overrides: object.__init__

_updateSupport(self, statistic)

 

Update support based on the latest statistic value

Parameters:
  • statistic (object) - Value of the statistic for the most recent sample

addSamples(self, n, finalize=True)

 

Add a maximum of n samples to the estimate

Parameters:
  • n (int) - Maximum number of samples to add
  • finalize (bool) - If True, finalize estimate value after adding samples

getEstimate(self, update=False)

 

Get the value of the Monte Carlo estimate. If no estimate available, calculate an estimate

Parameters:
  • update (bool) - If True, force re-calculation of the estimate.
Returns: object
Monte Carlo estimate

getNumSamples(self)

 

Return the number of samples used in the estimate so far

Returns: int
Number of samples drawn for the Monte Carlo estimate

getSampleFunction(self)

 

Return the sample function, which generates random samples

Returns: callable
Sample generating function, in the form f(): return sample

getStatisticFunction(self)

 

Get the function that calculates a statistic from a sample

Returns: callable
Function in form f(sample): return statistic