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

simple-linear-regression documentation incorrect? #38

Closed kovasap closed 2 years ago

kovasap commented 2 years ago

Here it says that simple-linear-regression returns a vector with [offset slope], but when I run it like this:

(transduce identity (kixi/simple-linear-regression :var1 :var2) [{:var1 1 :var2 2} {:var1 1 :var2 3}])

I get this thing in my browser log:

#object[kixi.stats.estimate.t_kixi$stats$estimate27271]

and I cannot use (first) or (last) to get the offset and slope respectively. Am I misunderstanding something about the transduce syntax perhaps?

henrygarner commented 2 years ago

Many thanks for reporting this, the docstring was outdated. The result you get is actually a kixi.stats.protocols/PParamaterised so can get the parameter vector by invoking kixi.stats.protocols/parameters on it.

kovasap commented 2 years ago

Got it, working as expected now. Thank you!

Also this library is great and easy to understand, especially for someone new to clojure like me :).