Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 80595 invoked from network); 24 Dec 2009 00:06:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 24 Dec 2009 00:06:00 -0000 Received: (qmail 48088 invoked by uid 500); 24 Dec 2009 00:05:59 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 47970 invoked by uid 500); 24 Dec 2009 00:05:59 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 47960 invoked by uid 99); 24 Dec 2009 00:05:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Dec 2009 00:05:59 +0000 X-ASF-Spam-Status: No, hits=-10.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Dec 2009 00:05:49 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 6672A234C045 for ; Wed, 23 Dec 2009 16:05:29 -0800 (PST) Message-ID: <1141381357.1261613129405.JavaMail.jira@brutus> Date: Thu, 24 Dec 2009 00:05:29 +0000 (UTC) From: "Phil Steitz (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (MATH-323) Add Semivariance calculation In-Reply-To: <995643514.1260563538298.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MATH-323?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12794279#action_12794279 ] Phil Steitz commented on MATH-323: ---------------------------------- Thanks, Larry. I am happy that you are not finding it too hard to get started contributing. We appreciate and welcome your contributions! Now to the eggnog...er, I mean issue at hand.... I now (think I) understand what you are trying to compute and get why you leave the top-coded entries in place. What now looks funny to me is to recode and then just compute ordinary variance. That will not give you E(X - MAR)^2, but rather E(X - E(recoded X))^2. I think you may need to directly compute the squared deviations from the MAR (or the mean with the top-coded entries contributing 0) instead of computing the variance on the recoded data. That seems to be what your second reference above is describing. Consider the influence of the original values greater than or equal to the mean in the result computed below: {code} for (int loop = 0; loop < values.length; loop++) { if (values [loop] < mean) semivariancevalues [loop] = values [loop]; else semivariancevalues [loop] = mean; } return VARIANCE.evaluate(semivariancevalues, mean); {code} The top-coded values will not contribute 0, but will instead contribute whatever their deviation is above the mean of the recoded dataset. Is this what you really want? It would seem to me that the more natural measure would be E(X - original mean)^2 Sorry to ask so many questions. Could well be I am just misunderstanding what the statistic is trying to estimate. I just want to make sure we are computing something that we can easily describe and more importantly what is really useful. Regarding the UnivariateStatistic, I think we should go ahead and do that and include the target as an optional constructor argument. > Add Semivariance calculation > ---------------------------- > > Key: MATH-323 > URL: https://issues.apache.org/jira/browse/MATH-323 > Project: Commons Math > Issue Type: New Feature > Affects Versions: 2.1 > Reporter: Larry Diamond > Assignee: Phil Steitz > Priority: Minor > Fix For: 2.1 > > Attachments: patch.txt, patch2.txt, StatUtils.java, StatUtils.java, StatUtilsTest.java, StatUtilsTest.java > > > I've added semivariance calculations to my local build of commons-math and I would like to contribute them. > Semivariance is described a little bit on http://en.wikipedia.org/wiki/Semivariance , but a real reason you would use them is in finance in order to compute the Sortino ratio rather than the Sharpe ratio. > http://en.wikipedia.org/wiki/Sortino_ratio gives an explanation of the Sortino ratio and why you would choose to use that rather than the Sharpe ratio. (There are other ways to measure the performance of your portfolio, but I wont bore everybody with that stuff) > I've already got the coding completed along with the test cases and building using mvn site. > The only two files I've modified is src/main/java/org/apache/commons/stat/StatUtils.java and src/test/java/org/apache/commons/math/stat/StatUtilsTest.java -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.