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

Phil Steitz commented on MATH-287:
----------------------------------

I committed a modified version of the patches above in r809448.  Changes from 
the patch are:
* Clarified javadoc in test(values, weights, begin, end) added to 
AbstractUnivariateStatistic.
* Added requirements that weights cannot be infinite or NaN and not all weights 
can be zero.
* Added a test to UnivariateStatisticAbstractTest to verify that when weights 
are frequency counts, weighted stats behave as expected.
* Changed formula in weighted product to exponentiate rather than multiply the 
weights.
* Changed and documented the formula used in weighted variance.

More things to do on these (and others to add):
* Add evaluate(values, weights)  - i.e., versions with no start, length 
parameters.
* Add tests to verify correct exception behavior on all bad parameter 
combinations.
* Replace naive loop in weighted variance with updating formula similar to 
unweighted.  I committed naive version so the formula would be clear and we 
could argue about it ;)

Re the weighted variance computation: there is no standard formula, as what E(X 
- E(X))^2 means based on a weighted sample depends on how you look at the 
weights.  The formula that I used is what the R hmisc package uses by default 
and is correct if the weights are frequency counts.  The normalization in the 
javadoc gives the same result as R when normwt=true.


> Add support for weighted descriptive statistics
> -----------------------------------------------
>
>                 Key: MATH-287
>                 URL: https://issues.apache.org/jira/browse/MATH-287
>             Project: Commons Math
>          Issue Type: New Feature
>    Affects Versions: 2.0
>            Reporter: Matthew Rowles
>            Priority: Minor
>         Attachments: weighted.patch, weightTests.patch
>
>
> Add support for weighted descriptive statistics, such as weighted variance.
> An example method call would be Variance.evaluate(double[] values, double[] 
> weights, int begin, int length)
> - Suggested by  [email protected] on the mailing list.

-- 
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