[ 
https://issues.apache.org/jira/browse/MATH-385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12888583#action_12888583
 ] 

Mikkel Meyer Andersen commented on MATH-385:
--------------------------------------------

I agree that we need to handle non-connected support, and a isSupportConnected 
might be a way to do it (dealing with it properly in {Lower, 
Upper}Bound-functions if it is not connected). Or else we should think of 
support as an array of supports, but I think that would complicate it all too 
much. But the idea might give rise to an Interval-class consisting of endpoints 
(lower and upper bounds) together with indication of whether they are inclusive 
or not, and whether the interval is continuous or discrete.

I would never expect to see NaN in support (I'm not sure if my expectations are 
valid), but in mean and variance it is very reasonable to expect a NaN, e.g. is 
neither mean nor variance defined for the Cauchy distribution.

Regarding the significance of the computations, you might be right. But I think 
it should be possible to specify not to do it before get()'ting the mean etc. 
E.g. is the mean for the Weibull constructed by computing a sum which might 
contain many terms depending on the parameters. It would not be a problem in 
3.0 when removing the ability to change the parameters. If we simply add a 
boolean isMeanCalculated etc. this behavior can easily be obtained.

> Characteristic (support, mean, variance, ...) on Distributions
> --------------------------------------------------------------
>
>                 Key: MATH-385
>                 URL: https://issues.apache.org/jira/browse/MATH-385
>             Project: Commons Math
>          Issue Type: New Feature
>            Reporter: Mikkel Meyer Andersen
>   Original Estimate: 5h
>  Remaining Estimate: 5h
>
> I wish that the Distributions could contain some characteristics. For example 
> support, mean, and variance.
> Support:
> AbstractContinuousDistribution and AbstractIntegerDistribution should have 
> double getSupport{Lower, Upper}Bound() and int getSupport{Lower, 
> Upper}Bound(), respectively. Also methods a la boolean isSupport{Lower, 
> Upper}BoundInclusive() on AbstractContinuousDistribution should reflect if 
> the support is open of closed. In practise the implemented distributions are 
> easy since the support for all continuous distributions are real intervals 
> (connected sets), and the support for all the discrete distributions are 
> connected integer sets. This means that the lower and upper bound (together 
> with isSupport{Lower, Upper}BoundInclusive() on 
> AbstractContinuousDistribution because it is not needed on the discrete 
> distributions because of their nature) are sufficient for determine the 
> support.
> Mean and variance:
> double get{Mean, Variance}() should be on AbstractDistribution.
> With such characteristic an invalidateParameters-method might come in handy 
> because they often depend on the parameters. The characteristics should not 
> be calculated before the first time they are get'ted, and when calculated, 
> they should be saved for later use.  When parameters change, an 
> invalidateParameters-method should be called to force the characteristics to 
> be recalculated.
> Values such as Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, and 
> Double.NaN should be used where appropriate.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to