Package BIP :: Package Bayes :: Package general :: Module bvariables :: Class _BayesVar
[hide private]
[frames] | no frames]

Class _BayesVar

source code

object --+
         |
        _BayesVar

Bayesian random variate.
Instance Methods [hide private]
 
__init__(self, disttype, pars, rang, resolution=1024)
Initializes random variable.
source code
 
__str__(self)
Returns: ascii histogram of the variable
source code
 
_flavorize(self, pt, ptbase)
Add methods from distribution type
source code
 
_update(self, model)
Calculate likelihood function
source code
 
add_data(self, data, model)
Updates variable with information from dataset
source code
 
get_prior_sample(self, n)
Returns a sample from the prior distribution
source code
 
get_prior_dist(self)
Returns the prior PDF.
source code
 
get_posterior_sample(self, n)
Return a sample of the posterior distribution.
source code
 
_likelihood(self, dname)
Defines parametric family of the likelihood function.
source code
 
_post_from_conjugate(self, dname, *pars)
Returns posterior distribution function using conjugate prior theory
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, disttype, pars, rang, resolution=1024)
(Constructor)

source code 
Initializes random variable.
Parameters:
  • disttype - must be a valid RNG class from scipy.stats
  • pars - are the parameters of the distribution.
  • rang - range of the variable support.
  • resolution - resolution of the support.
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Returns:
ascii histogram of the variable
Overrides: object.__str__

add_data(self, data, model)

source code 
Updates variable with information from dataset
Parameters:
  • data - sequence of numbers
  • model - probabilistic model underlying data

get_prior_sample(self, n)

source code 
Returns a sample from the prior distribution
Parameters:
  • n - Sample size.

get_posterior_sample(self, n)

source code 
Return a sample of the posterior distribution. Uses SIR algorithm.
Parameters:
  • n - Sample size.

_likelihood(self, dname)

source code 
Defines parametric family of the likelihood function. Returns likelihood function.
Parameters:
  • dname - must be a string.
Returns:
lambda function to calculate the likelihood.