MastodonC / kixi.stats

A library of statistical distribution sampling and transducing functions
https://cljdoc.xyz/d/kixi/stats
360 stars 18 forks source link

Behaviour when nil is passed as parameters to some functions #24

Closed mikeyford closed 2 days ago

mikeyford commented 5 years ago

Hiya Henry,

I'm interested in the intentions around the behavior of a handful of the kixi.stats.distribution functions when nil is passed to them. One familiar example is

(d/draw (d/beta-binomial 20 nil))
=> 8

Parameters of alpha=1, beta=1 have been used here implicitly, but this seems like slightly unsafe behavior to me because once a complex application has been built around this function it seems quite possible to unintentionally pass a nil into the function if something unexpected happens elsewhere, and things proceed as normal.

I would personally favour an error to be raised if I don't explicitly pass valid arguments to all of the distribution functions. However, perhaps this distribution is a special case with something I'm missing (and weibull, beta etc.) or the current behaviour facilitates some more complex uses, when things are used in transducing functions and the like?

Cheers, Mike