MastodonC / kixi.stats

A library of statistical distribution sampling and transducing functions
https://cljdoc.xyz/d/kixi/stats
Eclipse Public License 1.0
355 stars 17 forks source link

mean? #25

Closed danieroux closed 5 years ago

danieroux commented 5 years ago

https://github.com/MastodonC/kixi.stats/blob/15772f411397546964c0a1216d0e5a7d68a3d9f6/src/kixi/stats/core.cljc#L96

That should be

(/ c s)?

henrygarner commented 5 years ago

c and s are count and sum respectively. The arithmetic mean is the sum divided by the count, so (/ s c) is correct. The test here verifies the implementation against a straightforward equivalent.

danieroux commented 5 years ago

It is not computing the sum divided by count:

(kixi/mean [1 2 3]) => 1/2
henrygarner commented 5 years ago

The functions in kixi.stats/core are all reducing functions designed to work with transduce rather than be called directly. The usage section of the README should provide some helpful examples.

The arithmetic mean test should also reassure you that things are behaving as expected.

danieroux commented 5 years ago

Ah.

(transduce identity kixi.stats.core/mean [1 2 3]) => 2.0

Thank you.