Skip to content

Commit

Permalink
extras -> datasets, add funs for pde experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
mathematicalmichael committed Feb 1, 2021
1 parent 8bf29b3 commit 3fbbcbd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
File renamed without changes.
34 changes: 34 additions & 0 deletions src/mud_examples/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,40 @@ def extract_statistics(solutions, reference_value):
return means, variances


def experiment_measurements_index(fun, num_measurements, sd, num_trials, seed=21):
"""
Fixed sensors, varying how much data is incorporated into the solution.
"""
experiments = {}
solutions = {}
for ns in num_measurements:
ratios = []
mud_solutions = []
for t in range(num_trials):
np.random.seed(seed+t)
_r = fun(sd=sd, num_obs=ns)
ratios.append(_r)
mud_solutions.append(np.argmax(_r))
experiments[ns] = ratios
solutions[ns] = mud_solutions

return experiments, solutions


def extract_statistics_index(x, solutions, reference_value):
num_sensors_plot_conv = solutions.keys()
means = []
variances = []
for ns in num_sensors_plot_conv:
mud_solutions = [ x[_index] for _index in solutions[ns] ]
err = np.linalg.norm(np.array(mud_solutions) - reference_value, axis=1)/np.sqrt(len(reference_value))
mean_mud_sol = np.mean(err)
var_mud_sol = np.var(err)
means.append(mean_mud_sol)
variances.append(var_mud_sol)
return means, variances


def compare_mud_map_pin(A, b, d, mean, cov):
mud_pt = mud_sol(A, b, d, mean, cov)
map_pt = map_sol(A, b, d, mean, cov)
Expand Down

0 comments on commit 3fbbcbd

Please sign in to comment.