Well, the exponential, chi^2 and MaxwellBoltzman distributions are all
specializations of the gamma distribution.
If you working on a Montecarlo estimate where the parameters of your chi^2
distribution vary according to a hyperdistribution, then it would be nice
to implement the chi^2 distribution by changing the getter's for the two
parameters of the Gamma distribution to get the specialized values. Then it
would be nice to implement the generalized hyperdistributed chi^2 by
overriding the getters for the parameters of the chi^2 distribution to
sample from the hyperdistribution.
If you use getters throughout, then chi^2 is nearly a oneliner, the
hyperdistributed chi^2 is another oneliner. The JIT will optimize away
all of the abstractions and give a result that is as fast as any other
implementation.
You can complain that this example is contrived, but an over dispersed
exponential is a common concept and is best described in this same fashion.
It might be that you could do all of this eagerly, having the hyperchi^2
instantiate a new chi^2 which instantiates a new gamma for ever sample, but
then everybody has to be injecting a random number generator up and down the
chain (because those *are* often heavyweight and can't be instantiated
cheaply). Overriding the getters is way cleaner when you need to
implement.
On Fri, Mar 5, 2010 at 1:56 PM, Gilles Sadowski <
gilles@harfang.homelinux.org> wrote:
> Can you imagine a not contrived example? I.e. why would one inherit from a
> class while throwing away the implementation?
>

Ted Dunning, CTO
DeepDyve
