On 5 December 2012 17:38, Nicolas Cellier nicolas.cellier.aka.nice@gmail.com wrote:
2012/12/5 glenpaling slp5591@me.com:
I add these two methods to the math functions protocol of the Collections class:
variance
^(self - self average) squared average
and
standardDeviation
^self variance sqrt.
Be careful with large collections integers as these methods will invoke fraction arithmetic which is rather slow. In most cases it would be better to force floating point.
No, IMO the library shouldn't force anything but let the decision to the sender. Such information has a place in documentation.
Especially when forcing floats is as easy as (myCollection collect: #asFloat) standardDeviation.
frank
Nicolas
-- View this message in context: http://forum.world.st/statistics-standard-deviation-tp4655159p4658151.html Sent from the Squeak - Dev mailing list archive at Nabble.com.