def test_cauchy_posterior_sampling(self): """ Test whether the posterior can successully be sampled from """ counts = np.array((10, 103)) biases = np.array((10.0, 30.0)) esimator = MultinomialBayesEstimator(counts=counts, zetas=biases, prior='cauchy', location=0, spread=100) # Sample from the posterior esimator.sample_posterior(nwalkers=4, nmoves=10)
def test_bias_initialization(self): """ Assess whether the biases are correctly read in and appropriately set to zero if no biases are applied. """ # Initialize the class with fake samples counts = np.array((10, 103, 243, 82)) biases = np.array((0.0, 0.0, 0.0, 0.0)) esimator_biased = MultinomialBayesEstimator(counts=counts, zetas=biases) esimator_unbiased = MultinomialBayesEstimator(counts=counts) assert np.all( esimator_unbiased.free_energies == esimator_biased.free_energies)
def test_map_estimation(self): """ Test if the maximum aposteriori estimator works """ # Initialize the class with fake samples counts = np.array((10, 103, 243, 82)) biases = np.array((10.0, 30.0, 43.0, 28.0)) esimator = MultinomialBayesEstimator(counts=counts, zetas=biases, prior='gaussian', location=0, spread=100) map = esimator.map_estimator()
def test_map_estimation_stacked_inputs(self): """ Test if the maximum aposteriori estimator works when matrices are supplied for the counts and biases. """ # Initialize the class with fake samples counts = np.array(((10, 103, 243, 82), (30, 11, 23, 72))) biases = np.array(((10.0, 30.0, 43.0, 28.0), (4.0, 14.0, 36.0, 81.0))) esimator = MultinomialBayesEstimator(counts=counts, zetas=biases, prior='gaussian', location=0, spread=100) map = esimator.map_estimator()
def test_stacking_inputs(self): """ The class for Multinomial bayesian estimation should be able to handle histograms from simulations with different applied biases, this is achieved with using matrices of histograms and biases. """ counts = np.array(((10, 103, 243, 82), (30, 11, 23, 72))) biases = np.array(((10.0, 30.0, 43.0, 28.0), (4.0, 14.0, 36.0, 81.0))) esimator = MultinomialBayesEstimator(counts=counts, zetas=biases)