SciRuby / distribution

Probability distributions for Ruby.
http://sciruby.com/
Other
50 stars 21 forks source link

All normal distribution functions should accept mean and stddev parameters #23

Open agarie opened 9 years ago

agarie commented 9 years ago

The functions in Distribution::Normal doesn't accept mean and standard deviation parameters. Alright, we can scale the results ourselves, but this is awful practice. For example:

require 'distribution'

Distribution::Normal.rng(4.3, 0.3)
Distribution::Normal.cdf(3, 5)

What about having named parameters? The interesting part of not having named parameters is that I can provide an Array as in

params = [4.3, 0.3]
Distribution::Normal.rng(*params)

However, with named params:

named_params = { mean: 4.3, stddev: 0.3 }
Distribution::Normal.rng(**named_params)

named2 = { mean: 4.3, stddev: 0.3, stuff: nil }
Distribution::Normal.rng(**named2) # => ArgumentError: unknown keyword: stuff

Probably better.