Re: Problem applying generics to my code. Is there a better solution?



If I'm understanding you correctly

public static <T, P extends Distribution<?>> P conjugate(List<T>
data, Distribution<T> likelihood, P prior);

Now, conjugate sounds like a verb. Are you conjugating a likelihood
or a prior? Does it make sense to make the conjugate method into the
likelihood or prior object instead?

Which one of these three makes more sense?
"Likelihood, conjugate using data and prior":
likelihood.conjugate(data, prior)
or
"Prior, conjugate using data and likelihood":
prior.conjugate(data, likelihood)
or (where Data isn't just a List<T>)
"Data, conjugate using likelihood and prior):
data.conjugate(likelihood, prior)?

In this context "conjugate" is a property of the likelihood and the
prior distribution. It doesn't make a lot of sense to treat it as a
verb.

"A prior is CONJUGATE TO a likelihood iff the posterior
distribution has the same form as the prior"

A more natural purpose of a "conjugate" method would be a
conjugateTo() method to test for the property, e.g.

if ( prior.conjugateTo( likelihood ))
// Use fast, close-form solution
return prior.posterior( likelihood, data )
else
// Use slow, numerical simulation
return new Posterior( likelihood, data, prior );

.



Relevant Pages

  • Re: Problem applying generics to my code. Is there a better solution?
    ... but "Visitor pattern" is an application of the broadly useful ... important to constrain the return type to be the same as the prior ... parameters and force the data to be compatible with the likelihood. ... conjugate sounds like a verb. ...
    (comp.lang.java.programmer)
  • Re: Anyone found an Elementary Bayesian Book yet?
    ... is the answer given in cookbooks. ... prior, and I regret doing so now, because it introduced the ... RF> those in the likelihood function. ... RF> because the posterior is given by ...
    (sci.stat.math)
  • Re: Anyone found an Elementary Bayesian Book yet?
    ... prior, and I regret doing so now, because it introduced the ... RF> those in the likelihood function. ... RF> because the posterior is given by ...
    (sci.stat.math)
  • Re: Problem applying generics to my code. Is there a better solution?
    ... public class NormalDistribution implements Distribution ... public class GammaDistribution implements Distribution{... ... with the likelihood distribution and that the posterior distribution ... has the same domain as the prior -- the definition of a conjugate ...
    (comp.lang.java.programmer)