Skip to content

Instantly share code, notes, and snippets.

@unixpickle
Created June 14, 2017 20:35
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 unixpickle/5d9922b2012b21cebd94fa740a3a7103 to your computer and use it in GitHub Desktop.
Save unixpickle/5d9922b2012b21cebd94fa740a3a7103 to your computer and use it in GitHub Desktop.
Normalizing coefficient for tanh
package main
import (
"fmt"
"math"
"github.com/unixpickle/num-analysis/integration"
)
func main() {
v := integration.Integrate(func(x float64) float64 {
return math.Exp(-x*x/2) / math.Sqrt(2*math.Pi) * math.Pow(math.Tanh(x), 2)
}, integration.Interval{Start: -20, End: 20})
fmt.Println(1 / math.Sqrt(v))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment