0
我不太明白下面的代码,它计算数字列表的平均值和标准偏差:用于计算均值和标准差的代码是如何工作的?
let stats l =
let rec helper rest n sum sum_squares =
match rest with
| [] -> let nf = float_of_int n in
(sum /. nf, sqrt (sum_squares /. nf))
| h :: t ->
helper t (n+1) (sum+.h) (sum_squares +. (h*.h)) in
helper l 0 0.0 0.0;;
例如:
要其解释响应
val mean : float = 3.
val sd : float = 3.3166247903554
In
helper t (n+1) (sum+.h) (sum_squares +. (h*.h)) in
helper l 0 0.0 0.0;;
in
和helper l 0 0.0 0.0
是什么意思?
谢谢。