forked from ematvey/gostat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht.go
28 lines (25 loc) · 730 Bytes
/
t.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package stat
import (
. "github.com/ematvey/go-fn/fn"
)
func StudentsT_PDF(ν float64) func(x float64) float64 {
normalization := Γ((ν+1)/2) / (sqrt(ν*π) * Γ(ν/2))
return func(x float64) float64 {
return normalization * pow(1+x*x/ν, -(ν+1)/2)
}
}
func StudentsT_LnPDF(ν float64) func(x float64) float64 {
normalization := LnΓ((ν+1)/2) - log(sqrt(ν*π)) - LnΓ(ν/2)
return func(x float64) float64 {
return normalization + log(1+x*x/ν)*-(ν+1)/2
}
}
//StudentsT(ν) => N(0, 1)*sqrt(ν/NextGamma(ν/2, 2))
func NextStudentsT(ν float64) float64 {
return NextNormal(0, 1) * sqrt(ν/NextGamma(ν/2, 2))
}
func StudentsT(ν float64) func() float64 {
return func() float64 {
return NextStudentsT(ν)
}
}