Skip to content

Instantly share code, notes, and snippets.

@r9y9
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r9y9/edd779e58130b75d7ab5 to your computer and use it in GitHub Desktop.
Save r9y9/edd779e58130b75d7ab5 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math"
)
func HermitePolynomialsProb(x float64, n int) float64 {
norm := float64(factorial(n))
y := 0.0
bound := math.Floor(float64(n) / 2.0)
for m := 0; m <= int(bound); m++ {
y += math.Pow(-1, float64(m)) * math.Pow(x, float64(n-2*m)) /
(float64(factorial(m)) * float64(factorial(n-2*m)) *
math.Pow(2, float64(m)))
}
return y * norm
}
func factorial(x int) int {
if x == 0 {
return 1
}
return x * factorial(x-1)
}
func main() {
fmt.Println("Hello Hermite Polynomials.")
for i := 0; i < 10; i++ {
fmt.Println(HermitePolynomialsProb(0, i))
}
}
@r9y9
Copy link
Author

r9y9 commented May 31, 2014

scipy.special.hermitenorm 的なの

@r9y9
Copy link
Author

r9y9 commented May 31, 2014

Derivative of Gaussianの計算に使う

@r9y9
Copy link
Author

r9y9 commented Jun 1, 2014

http://play.golang.org/p/0ukIb_vASq
最初からこうすればよかった

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment