Bug #17054 [NEW]: Percentile Stat Function

From: Date: Wed, 10 Feb 2010 15:00:42 +0000
Subject: Bug #17054 [NEW]: Percentile Stat Function
Groups: php.pear.webmaster 
Request: Send a blank email to pear-webmaster+get-6687@lists.php.net to get a copy of this message
From: jgrant at chks dot co dot uk Operating system: Linux Package version: PHP version: 5.2.10 Package: Bug System Bug Type: Bug Bug description: Percentile Stat Function Description: ------------ When using the "stats_stat_percentile" function, the array passed in is being modified, regardless of how you pass it in. For example: $tmpArray contains: Array ( [51] => 150 [52] => 178 [53] => 116 [54] => 109 [61] => 45 [62] => 29 [63] => 26 [64] => 42 [71] => 32 [72] => 100 [73] => 120 [74] => 122 [81] => 54 [82] => 64 [83] => 51 [84] => 42 [91] => 46 [92] => 67 ) When used with the code to reproduce below, is being modified to the array below: Array ( [0] => 26 [1] => 29 [2] => 32 [3] => 42 [4] => 42 [5] => 45 [6] => 46 [7] => 51 [8] => 54 [9] => 64 [10] => 67 [11] => 100 [12] => 109 [13] => 116 [14] => 120 [15] => 122 [16] => 150 [17] => 178 ) Since I am not passing in the array to my function by reference, I would expect a 'copy' of my array to be used, leaving my original array intact. Reproduce code: --------------- $tmpArray = array("51" => 150, "52" => 178, "53" => 116, "54" => 109, "61" => 45, "62" => 29, "63" => 26, "64" => 42, "71" => 32, "72" => 100, "73" => 120, "74" => 122, "81" => 54, "82" => 64, "83" => 51, "84" => 42, "91" => 46, "92" => 67); list($percent05, $percent95) = percentiles($tmpArray); print "<pre>"; print_r($tmpArray); print "</pre>"; function percentiles($newArray) { $percent05 = stats_stat_percentile($newArray, 0.05); $percent95 = stats_stat_percentile($newArray, 0.95); return(array($percent05, $percent95)); } Expected result: ---------------- Array ( [51] => 150 [52] => 178 [53] => 116 [54] => 109 [61] => 45 [62] => 29 [63] => 26 [64] => 42 [71] => 32 [72] => 100 [73] => 120 [74] => 122 [81] => 54 [82] => 64 [83] => 51 [84] => 42 [91] => 46 [92] => 67 ) Actual result: -------------- Array ( [0] => 26 [1] => 29 [2] => 32 [3] => 42 [4] => 42 [5] => 45 [6] => 46 [7] => 51 [8] => 54 [9] => 64 [10] => 67 [11] => 100 [12] => 109 [13] => 116 [14] => 120 [15] => 122 [16] => 150 [17] => 178 ) -- Edit bug report at http://pecl.php.net/bugs/bug.php?id=17054&edit=1 --

« previous php.pear.webmaster (#6687) next »