Skip to content
Snippets Groups Projects
Commit 16041926 authored by Colm Talbot's avatar Colm Talbot
Browse files

Merge branch 'allow-multiple-sample-draws' into 'master'

Allow multiple prior draws

See merge request Monash/tupak!33
parents 03782eae 200846a8
No related branches found
No related tags found
1 merge request!33Allow multiple prior draws
Pipeline #
......@@ -17,11 +17,11 @@ class Prior(object):
self.latex_label = latex_label
def __call__(self):
return self.sample(1)
return self.sample()
def sample(self, n_samples=None):
"""Draw a sample from the prior, this rescales a unit line element according to the rescaling function"""
return self.rescale(np.random.uniform(0, 1, n_samples))
def sample(self, size=None):
"""Draw a sample from the prior """
return self.rescale(np.random.uniform(0, 1, size))
def rescale(self, val):
"""
......@@ -34,7 +34,9 @@ class Prior(object):
@staticmethod
def test_valid_for_rescaling(val):
"""Test if 0 < val < 1"""
if (val < 0) or (val > 1):
val = np.atleast_1d(val)
tests = (val < 0) + (val > 1)
if np.any(tests):
raise ValueError("Number to be rescaled should be in [0, 1]")
def __repr__(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment