Closed Smoren closed 1 year ago
This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Totals | |
---|---|
Change from base Build 4462214447: | 0.002% |
Covered Lines: | 787 |
Relevant Lines: | 788 |
Hi @markrogoyski, thank you, I used zipEqual()
as you suggested.
Also I added Stream::frequencies()
method and covered it with test.
BTW, I what do you think about a new namespace like Stat
for this function? Or maybe use Math
?
Hi @Smoren,
Thank you for this pull request, and apologies at the delay at reviewing it.
I have a suggestion, let's create two functions, using the technical definitions:
frequencies
which will return the number of times an item occurs. See frequency definition. relativeFrequencies
which will return the ratio of the frequency against the total count (Which is what you have implemented already). See relative frequency defintionFor reference, this is also the same terminology used in MathPHP.
use MathPHP\Statistics\Distribution;
$grades = ['A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'D', 'F'];
// Frequency distributions (frequency and relative frequency)
$frequencies = Distribution::frequency($grades); // [ A => 2, B => 4, C => 2, D => 1, F => 1 ]
$relative_frequencies = Distribution::relativeFrequency($grades); // [ A => 0.2, B => 0.4, C => 0.2, D => 0.1, F => 0.1 ]
Thoughts about this change? Thanks, Mark
Hi @markrogoyski,
Your suggestion is implemented!
Hi @Smoren,
Thanks for implementing the change. Looks good to me.
Mark
Thank you @markrogoyski!
Hi @Smoren,
Considering one of your earlier comments a bit more, I moved this functionality into the Math
namespace. It seems a better fit there.
Thanks again, Mark
Thank you @markrogoyski!
Hi @markrogoyski,
This is a draft of PR. If you like my implementation, I'll finish it.
BTW I think this method is more suitable for
Single
namespace, not forReduce
(as you suggest) because it returns a generator.