Commit cf4e4c18 authored by Azat Garifullin's avatar Azat Garifullin
Browse files

Initial commit

File added
File added
import os
import pickle
import random
import numpy as np
import matplotlib
from matplotlib import pyplot as plt
import random_fields as rf
def prior_sampler(_):
return [
np.random.uniform(0.5, 2.5),
np.random.uniform(0.5, 5),
np.random.uniform(0.5, 5)
def make_neg_log_posterior(observation):
def impl(state, proposal_field, field_cov):
return rf.matern_parameter_posterior_nl(observation, proposal_field, field_cov)
return impl
def main():
with open('./data/field.pickle', 'rb') as f:
xs, ys, field, nu, sigma, l = pickle.load(f)
print("Pre-evaluating distance matrix")
dist_mtx = rf.dist_matrix(xs, ys)
flat_field = np.ravel(field)
initial = (prior_sampler(0), flat_field)
field_sampler = rf.make_matern_sampler(dist_mtx)
neg_log_posterior = make_neg_log_posterior(flat_field)
print("Starting MCMC")
chain_res = rf.gibbs_metropolis(initial, prior_sampler,
neg_log_posterior, field_sampler)
with open('./data/matern_chain.pickle', 'wb') as f:
pickle.dump(chain_res, f)
if __name__ == '__main__':
\ No newline at end of file
File added
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment