mirror of https://github.com/djcb/mu.git
* guile: add mu:count to (mu stats)
This commit is contained in:
parent
11b60b7ca0
commit
99778d1314
|
@ -23,6 +23,7 @@
|
||||||
:use-module (ice-9 i18n)
|
:use-module (ice-9 i18n)
|
||||||
:use-module (ice-9 r5rs)
|
:use-module (ice-9 r5rs)
|
||||||
:export ( mu:tabulate
|
:export ( mu:tabulate
|
||||||
|
mu:count
|
||||||
mu:average
|
mu:average
|
||||||
mu:stddev
|
mu:stddev
|
||||||
mu:correl
|
mu:correl
|
||||||
|
@ -49,6 +50,17 @@ get back a list like
|
||||||
expr)
|
expr)
|
||||||
table))
|
table))
|
||||||
|
|
||||||
|
|
||||||
|
(define* (mu:count #:optional (expr #t))
|
||||||
|
"Count the number of messages matching EXPR. If EXPR is not
|
||||||
|
provided, match /all/ messages."
|
||||||
|
(let ((num 0))
|
||||||
|
(mu:for-each-message
|
||||||
|
(lambda (msg) (set! num (1+ num)))
|
||||||
|
expr)
|
||||||
|
num))
|
||||||
|
|
||||||
|
|
||||||
(define (average lst)
|
(define (average lst)
|
||||||
"Calculate the average of a list LST of numbers, or #f if undefined."
|
"Calculate the average of a list LST of numbers, or #f if undefined."
|
||||||
(if (null? lst)
|
(if (null? lst)
|
||||||
|
@ -96,7 +108,7 @@ and 2, respectively."
|
||||||
(sxy (apply + (map (lambda (cell) (* (car cell) (cdr cell))) lst)))
|
(sxy (apply + (map (lambda (cell) (* (car cell) (cdr cell))) lst)))
|
||||||
(sxx (apply + (map (lambda (cell) (* (car cell) (car cell))) lst)))
|
(sxx (apply + (map (lambda (cell) (* (car cell) (car cell))) lst)))
|
||||||
(syy (apply + (map (lambda (cell) (* (cdr cell) (cdr cell))) lst))))
|
(syy (apply + (map (lambda (cell) (* (cdr cell) (cdr cell))) lst))))
|
||||||
(/ (- (* n sxy) (* sx sy))
|
(/ (- (* n sxy) (* sx sy))
|
||||||
(sqrt (* (- (* n sxx) (* sx sx)) (- (* n syy) (* sy sy)))))))
|
(sqrt (* (- (* n sxx) (* sx sx)) (- (* n syy) (* sy sy)))))))
|
||||||
|
|
||||||
(define* (mu:correl func1 func2 #:optional (expr #t))
|
(define* (mu:correl func1 func2 #:optional (expr #t))
|
||||||
|
|
Loading…
Reference in New Issue