Open null-a opened 8 years ago
We could alias it to scorer
.
i have mixed feelings about this. on the one hand, we do need to clean up the confusion about dist.score(val)
vs sample(dist)
. introducing score(dist, val)
is the most straightforward solution.
on the other hand, it is much more idiomatic in js to use method calls, and i like dist.score(val)
. the other solution would be to make dist.sample()
alias to the co-routine sampler within webppl. this might be tricky to do, and kind of ugly while #358 is open...
If we're planning to address #358 before 1.0 (which would be desirable, as it would help a lot with making bigger models more modular), I'd just keep sample
/score
as they are for now, and then introduce dist.sample()
as the canonical way to sample from distributions. If we don't expect that we'll get to #358 for 1.0, I'm in favor of introducing the score
helper.
It’s probably confusing that sometimes the correct way to interact with a distribution is to call a method on it (e.g.
dist.score(x)
), and sometimes it’s to call a top-level function (e.g.sample(dist)
). Perhaps we should addscore(dist, x)
for consistency, and promote its use.Note that we already have
entropy
andMAP
helpers that serve a similar purpose to the proposedscore
function.@stuhlmueller pointed out that a minor consideration here is that people commonly use
score
as a variable name.