Mike Simmons wrote:(...) Didn't you originally want a TreeMap<Double, T> rather than a TreeMap<T, Double>?
Travis Risner wrote:Jon, first a question for Piet.
Piet, did you mean to use a forward slash rather than a backslash in your reply?
salvin francis wrote:(...) I love that piet too is thinking in my way that a cell simply is there or is not there, there is no state to it.
Mike Simmons wrote:Hi Piet, Stephen. I'm enjoying this - I hope you are too.
Stephan van Hulst wrote:
Piet Souris wrote:thanks for the critiques, even if it is not very egoless!
If, going by the description of peer reviews that I found on the Wiki for egoless programming, you mean that my review wasn't friendly or collegial, I apologize. I try to write in a neutral way but that doesn't always come across through text.
I find it really strange that you like using Java's functional features so much Piet, but then shirk the 'proper way' of doing things in preference of using hacks like modifying objects to get around the limitation that you can't modify local variables from lambdas, which is there for a good reason.
The forEach() in your cdf2() method is not functional. It's procedural code. Then why not just use a for-each loop? That way you won't even have to resort to silly things like using the array.
Why is your CDF keyed by probability? A CDF returns a probability given an observation, so it makes sense to keep T as the key.
You use two collect() operations in your cdf() method. That's wasteful. Use a downstream collector to specify what should be done with the values of the map while the groupingBy() is doing its magic.
I'd call cdf() getCumulativeDistribution()
Why is T a Number? The only thing that your methods require about T is that it has a natural order.