Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 92A4A17701 for ; Fri, 18 Sep 2015 21:40:09 +0000 (UTC) Received: (qmail 31988 invoked by uid 500); 18 Sep 2015 21:40:04 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 31900 invoked by uid 500); 18 Sep 2015 21:40:04 -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 31886 invoked by uid 99); 18 Sep 2015 21:40:04 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Sep 2015 21:40:04 +0000 Date: Fri, 18 Sep 2015 21:40:04 +0000 (UTC) From: "Marc Rosen (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (MATH-1277) Incorrect Kendall Tau calc due to data type mistmatch MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Marc Rosen created MATH-1277: -------------------------------- Summary: Incorrect Kendall Tau calc due to data type mistmatch Key: MATH-1277 URL: https://issues.apache.org/jira/browse/MATH-1277 Project: Commons Math Issue Type: Bug Affects Versions: 3.5 Reporter: Marc Rosen Priority: Minor The Kendall Tau calculation returns a number from -1.0 to 1.0 due to a mixing of ints and longs, a mistake occurs on large size columns (arrays) passed to the function. an array size of > 50350 triggers the condition in my case - although it may be data dependent the ver 3.5 library returns 2.6 as a result (outside of the defined range of Kendall Tau) with the cast to long below - the result reutns to its expected value commons.math3.stat.correlation.KendallsCorrelation.correlation here's the sample code I used: I added the cast to long of swaps in the int swaps = 1077126315; final long numPairs = sum(50350 - 1); long tiedXPairs = 0; long tiedXYPairs = 0; long tiedYPairs = 0; final long concordantMinusDiscordant = numPairs - tiedXPairs - tiedYPairs + tiedXYPairs - 2 * (long) swaps; final double nonTiedPairsMultiplied = 1.6e18; double myTest = concordantMinusDiscordant / FastMath.sqrt(nonTiedPairsMultiplied); -- This message was sent by Atlassian JIRA (v6.3.4#6332)