Closed nhirschey closed 2 years ago
Thanks for reporting the issue and updating the XML comments regarding the sorting.
Regarding 1: The performance of Quantile.compute
now seems decreased due to the sorting step, that makes the function always slower than it's alternatives. The original Quantile.compute
function is quick (as long as there are no duplicates) because there is no need for prior sorting steps.
Regarding 2: The generalization of the function is good but if called many times, the toArray conversion could slow down the evaluation if the input type already is of type array. A possible solution would be to check the input sequence type with .GetType().isArray
and if true, no Seq.toArray is applied. But I have to check the performance difference if my hypothesis is true.
Thanks again, I'll come back at you soon :rocket:
Ok, fair enough. I understand you wanting to have the fast version available. I just pushed a changed that did the following:
Seq.UtilityFunctions.toArrayQuick
so that Array inputs won't be converted, taken from Don here so it's presumably the fastest way to do this.So in summary, the changes in this PR now are 1) fixes comments and 2) allow seq input. In my unscientific tests it looks like it's back to the same performance as the developer
branch on array inputs.
Thank you for your thoughtful consideration of my issues this week; I know I've already burnt a lot of your time on this!
Edit: I thought I marked Seq.UtilityFunctions.toArrayQuick as internal but I didn't. I'll leave as is so that I don't keep bothering you with notifications, but feel free to use this PR, reject it, or modify it in any way at your leisure.
I'm always happy if FSharp.Stats is improved and I learned much on this journey, so it never is wasted time :+1: You didn't forget the internal, it is there :wink: Thanks for your time and work.
To boost the performance further I added a toArrayCopyQuick
function. If the input sequence is not an array, a new array is created and there is no need for copying. If the input is an array, it should be copied to not interfere with the in-place operations.
Additionally, I added unit tests for most of the Quantile functions so finally these module is covered :+1:
toArrayCopyQuick is a great idea.
Two changes:
Description
With this build:
[Required] please make sure you checked that
[Optional]