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

Possible to combine simulate and loss functions? #10

Closed
pcjentsch opened this issue Jun 15, 2020 · 3 comments
Closed

Possible to combine simulate and loss functions? #10

pcjentsch opened this issue Jun 15, 2020 · 3 comments

Comments

@pcjentsch
Copy link

Hi,

Thanks for the great package. Is it possible to create an interface that combines the simulate and distance functions into one function that is evaluating at inputs and returns real numbers? Is there a workaround I can use for this?

My loss function is quite complex and separating the simulation from the distance, while possible, just makes my code more complex.

Before the most recent patch, I was able to work around this as the distance always used the second argument for tdata, but that seems to have changed.

Thanks!

@francescoalemanno
Copy link
Owner

francescoalemanno commented Jun 15, 2020

edited:

This issue can be worked around :)
you can use this function in your code:

function ABCplan(prior,costfunction;params=())
    fakedist(x,y)=x+y
    ABCplan(prior, costfunction, 0.0, fakedist; params=params)
end

example:

prior = Normal(0,1)
sim(x,other) = abs(x-1.5) #it returns a distance value
plan=ABCplan(prior, sim)
@show mean(ABCDE(plan,0.01,verbose=false)[1])
# mean((ABCDE(plan, 0.01, verbose = false))[1]) = 1.4993631135745822

@francescoalemanno
Copy link
Owner

as soon as the whole code stabilizes, i will maybe incorporate a function similar to that one inside the package, for now i added a test to make sure i don't accidentally prevent a use of my package via distance values only :)

@pcjentsch
Copy link
Author

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants