Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 93728 invoked from network); 27 Sep 2009 14:13:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Sep 2009 14:13:46 -0000 Received: (qmail 28584 invoked by uid 500); 27 Sep 2009 14:13:45 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 28448 invoked by uid 500); 27 Sep 2009 14:13:45 -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 28436 invoked by uid 99); 27 Sep 2009 14:13:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 Sep 2009 14:13:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED 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; Sun, 27 Sep 2009 14:13:36 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 2B0CC234C051 for ; Sun, 27 Sep 2009 07:13:16 -0700 (PDT) Message-ID: <1522387978.1254060796175.JavaMail.jira@brutus> Date: Sun, 27 Sep 2009 07:13:16 -0700 (PDT) From: "Romeo Palijan (JIRA)" To: issues@commons.apache.org Subject: [jira] Reopened: (MATH-296) LoessInterpolator.smooth() not working correctly In-Reply-To: <878072684.1253135757547.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MATH-296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Romeo Palijan reopened MATH-296: -------------------------------- Eugene, Luc, thanks. Great news. I have been testing this with some bigger real-life datasets (~800 points) and the results seem to be very close to R). There is one more problem though but I think I have already found the fix. You can still get NaN-results. The reason is that sumWeights can become 0 and there are a couple of divisions with sumWeights. This multiplies to the degree that the complete result set is an array of NaN. I think (but am not sure) that this happens if you have a long series of 0-weights which is bigger then the amount of points you get through the bandwidth. I have just added the following lines after these sumWeights divisions: after: *double meanXSquared = sumXSquared / sumWeights;* if(sumWeights==0){ meanX=0; meanY=0; meanXY=0; meanXSquared=0; } That did the trick for me and the results seem accurate. I will test more during the next week with even more datasets. I hope I do not make any fundamental thinking error. If you think this is correct please add it to the code. > LoessInterpolator.smooth() not working correctly > ------------------------------------------------ > > Key: MATH-296 > URL: https://issues.apache.org/jira/browse/MATH-296 > Project: Commons Math > Issue Type: Bug > Affects Versions: 2.0 > Environment: Java 1.6 on Vista > Reporter: Romeo Palijan > Fix For: 2.1 > > Attachments: math-296-test.patch, math-296.patch > > > I have been comparing LoessInterpolator.smooth output with the loessFit output from R (R-project.org, probably the most widely used loess implementation) and have had strangely different numbers. I have created a small set to test the difference and something seems to be wrong with the smooth method but I do no know what and I do not understand the code. > *Example 1* > |x-input: |1.5| 3.0| 6| 8| 12|13| 22| 24|28|31| > |y-input: |3.1|6.1|3.1|2.1|1.4|5.1|5.1|6.1|7.1|7.2| > |Output LoessInterpolator.smooth():|NaN|NaN|NaN|NaN|NaN|NaN|NaN|NaN|NaN|NaN| > |Output from loessFit() from R: |3.191178027520974|3.0407201231474037|2.7089538903778636|2.7450823274490297|4.388011000549519|4.60078952381848|5.2988217587114805|5.867536388457898|6.7797794777879705|7.444888598397342| > *Example 2 (same x-values, y-values just floored)* > |x-input: |1.5| 3.0| 6| 8| 12|13| 22| 24|28|31| > |y-input: |3|6|3|2|1|5|5|6|7|7| > |Output LoessInterpolator.smooth(): |3|6|3|2|0.9999999999999005|5.0000000000001705|5|5.999999999999972|7|6.999999999999967| > |Output from loessFit() from R: |3.091423927353068|2.9411521572524237|2.60967950675505|2.7421759322272248|4.382996912300442|4.646774316632562|5.225153658563424|5.768301917477015|6.637079139313073|7.270482144410326| > As you see the output is practically the replicated y-input. > At this point this funtionality is critical for us but I could not find any other suitable java-implementation. Help. Maybe this strange behaviour gives someone a clue? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.