Passing my observed data to distance()
See original GitHub issueI have a rather simple setup with a list of observed data (plus some other parameters), a custom synthetic data generator function, and a custom and distance estimator between the observed and synthetic data.
I don’t understand how to pass the observed data to the distance()
function. Below is a (non-working) minimal example of my setup. Could you point me on how I should modify this to make it work please?
import pyabc
import os
import tempfile
from . import synth_data_generator, custom_dist
# This list contains data required for the synth_data_generator() function
synth_args = [...]
# This list contains my observed data and some other objects required for
# my custom_dist() function
obs_data = [...]
def model(parameter):
model_p = (parameter['A'], parameter['B'])
synth_data = synth_data_generator(model_p, *synth_args)
return synth_data
def distance(synth_data):
return custom_dist(synth_data, obs_data)
prior = pyabc.Distribution(A=pyabc.RV("uniform", 0, 1), B=pyabc.RV("uniform", 100, 10000))
abc = pyabc.ABCSMC(model, prior, distance, population_size=10)
db_path = ("sqlite:///" + os.path.join(tempfile.gettempdir(), "test.db"))
abc.new(db_path)
history = abc.run(minimum_epsilon=.1, max_nr_populations=10)
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
MATLAB pdist2 - MathWorks
This MATLAB function returns the distance between each pair of observations in X and Y using the metric specified by Distance.
Read more >Distance Matrix Computation - R
This function computes and returns the distance matrix computed by using the specified distance measure to compute the distances between the rows of...
Read more >Cluster Analysis in R - RPubs
The dist() function simplifies this process by calculating distances between our observations (rows) using their features (columns).
Read more >Regression Diagnostics - SPH - Boston University
The Cook's distance statistic is a measure, for each observation in turn, of the extent of change in model estimates when that particular...
Read more >Distance Sampling Detection Function and Abundance ...
Format. A data.frame with 112 observations on the following 9 variables. • Sample.Label name of single transect. • Effort transect length (km).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
With minimal modifications, the code in your third comment should look like:
Thank you Yannik