Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change pocomc.Prior object to use a global Pipeline variabkle #137

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions cosmosis/samplers/poco/poco_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ def log_likelihood(p):


class Prior:
def __init__(self, pipeline):
self.pipeline = pipeline
self.dim = len(self.pipeline.varied_params)
self.bounds = np.array([p.limits for p in self.pipeline.varied_params])
def __init__(self):
self.dim = len(pipeline.varied_params)
self.bounds = np.array([p.limits for p in pipeline.varied_params])

def logpdf(self, x):
return np.array([self.pipeline.prior(p) for p in x])
return np.array([pipeline.prior(p) for p in x])

def rvs(self, size=None):
return np.array([self.pipeline.randomized_start() for i in range(size)])
return np.array([pipeline.randomized_start() for i in range(size)])


class PocoMCSampler(ParallelSampler):
Expand Down Expand Up @@ -73,7 +72,7 @@ def config(self):

# Finally we can create the sampler
self.sampler = self.pocomc.Sampler(
prior=Prior(self.pipeline),
prior=Prior(),
likelihood=log_likelihood,
random_state=seed,
n_effective=self.n_effective,
Expand Down
Loading