-
Notifications
You must be signed in to change notification settings - Fork 2k
Measures.Quartiles: value for Q1 (lower quartile) wrong in QuantileMethod.R #865
Comments
Hi @hkoestin, Thanks for opening the issue! As a workaround, you can sort the values before calling the Quartiles method while also passing double m = Measures.Quartiles(v1.Sorted(), out q1, out q3, alreadySorted: true, type: QuantileMethod.R); I am still investigating where the problem actually is, but I hope the workaround can solve the issue for you in the meantime! Thanks again, |
By the way, regarding the second vector, I am getting a value of 9.25 in R instead of the indicated 11.25. This matches with the framework once the values have been sorted manually with the workaround above. So I hope the workaround will really work for you, but if you find another case that it fails, please let me know. Regards, |
…ment partial sorting; Updating the Quantile methods to use this method instead of NthElement; - Updates GH-865: Measures.Quartiles: value for Q1 (lower quartile) wrong in QuantileMethod.R
@cesarsouza 👍 I will include the fix for sorting the values first. Thanks again! |
Did the fix with the code suggestion from above. Works fine now. If you want to or need them, here is my set of test-vectors for the regression tests against R-compatibility, used to execute xUnit Theories. First double[] is the input vector. new object[]
{
new double?[] {0.0, 1.0, 2.0, 4.0, 5.4, 3.5, 7.8, 8.9, 17.0, 23.78, 98.9, 2.3, 4.5, 6.7, 9.34, 42.42},
3.2, 11.255
},
new object[]
{
new double?[] {0.0, 5.4, 2.0, 4.0, 1.0, 3.5, 7.8, 17.0, 8.9, 98.9, 23.78, 2.3, 4.5, 6.7, 42.42, 9.34},
3.2, 11.255
},
new object[]
{
new double?[]
{
0.0, 1.0, 2.0, 4.0, 5.4, 3.5, 7.8, 8.9, 17.0, 23.78, 98.9, 2.3, 4.5, 6.7, 9.34, 42.42, 23, 17.87, 18.54, 16.23, 15.34,
19.8723, 23, 24.32
},
4.375, 20.65423
},
new object[]
{
new double?[]
{
18, 31, 25, 2, 22, 13, 37, 1, 4, 7, 6, 45, 10, 24, 23, 49, 27, 9, 35, 14, 34, 33, 41, 42, 20, 43, 3, 48, 15, 39, 11, 38,
46, 17, 40, 16, 50, 29, 19, 47, 12, 28, 32, 8, 30, 26, 5, 44, 36, 21
},
13.25, 37.75
},
new object[]
{
new double?[]
{
18, 14, 1, 15, 4, 32, 10, 26, 38, 9, 24, 16, 31, 20, 25, 30, 22, 6, 28, 21, 33, 17, 5, 35, 2, 13, 36, 8, 29, 7
},
9.25, 28.75
},
new object[]
{
new double?[]
{
112, 718, 320, 576, 547, 658, 253, 560, 408, 314, 681, 303, 236, 753, 122, 239, 222, 797, 593, 274, 338, 604, 52, 245,
389
},
245, 593
},
new object[]
{
new double?[]
{
209, 556, 317, 571, 219, 599, 568, 516, 582, 279, 298, 319, 614, 290, 458, 262, 281, 606, 513, 519, 356, 338, 525, 576,
180
},
290, 568
} |
- Updates GH-865: Measures.Quartiles: value for Q1 (lower quartile) wrong in QuantileMethod.R
Thanks @hkoestin! I've committed a fix to the issue yesterday and it has passed all test vectors above. The fix should be included in the next (pre-)release. Regards, |
Added in 3.8.0. |
Hello @cesarsouza
I just found out, that the calculation for the lower quartile (25% quantile) is not working correctly, when passing in QuantileMethod.R as method.
I have the following vector:
For this vector, I get the following results for the Q1 value:
Don't know though, where the difference is coming from.
For some other samples I get correct results.
Cheers, Harald
The text was updated successfully, but these errors were encountered: