Well, the exponential, chi^2 and Maxwell-Boltzman distributions are all specializations of the gamma distribution.
If you working on a Monte-carlo estimate where the parameters of your chi^2 distribution vary according to a hyper-distribution, 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 hyper-distributed chi^2 by over-riding the getters for the parameters of the chi^2 distribution to sample from the hyper-distribution. If you use getters throughout, then chi^2 is nearly a one-liner, the hyper-distributed chi^2 is another one-liner. 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 hyper-chi^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). Over-riding the getters is way cleaner when you need to implement. On Fri, Mar 5, 2010 at 1:56 PM, Gilles Sadowski < gil...@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