mirror of
https://github.com/gonum/gonum.git
synced 2025-10-21 14:19:35 +08:00

Changes made in dsp/fourier/internal/fftpack break the formatting used there, so these are reverted. There will be complaints in CI. [git-generate] gofmt -w . go generate gonum.org/v1/gonum/blas go generate gonum.org/v1/gonum/blas/gonum go generate gonum.org/v1/gonum/unit go generate gonum.org/v1/gonum/unit/constant go generate gonum.org/v1/gonum/graph/formats/dot go generate gonum.org/v1/gonum/graph/formats/rdf go generate gonum.org/v1/gonum/stat/card git checkout -- dsp/fourier/internal/fftpack
34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
// Copyright ©2016 The Gonum Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package mathext
|
|
|
|
import "gonum.org/v1/gonum/mathext/internal/cephes"
|
|
|
|
// RegIncBeta returns the value of the regularized incomplete beta function
|
|
// I(x;a,b). It is defined as
|
|
//
|
|
// I(x;a,b) = B(x;a,b) / B(a,b)
|
|
// = Γ(a+b) / (Γ(a)*Γ(b)) * int_0^x u^(a-1) * (1-u)^(b-1) du.
|
|
//
|
|
// The domain of definition is 0 <= x <= 1, and the parameters a and b must be positive.
|
|
// For other values of x, a, and b RegIncBeta will panic.
|
|
func RegIncBeta(a, b float64, x float64) float64 {
|
|
return cephes.Incbet(a, b, x)
|
|
}
|
|
|
|
// InvRegIncBeta computes the inverse of the regularized incomplete beta function.
|
|
// It returns the x for which
|
|
//
|
|
// y = I(x;a,b)
|
|
//
|
|
// The domain of definition is 0 <= y <= 1, and the parameters a and b must be
|
|
// positive. For other values of x, a, and b InvRegIncBeta will panic.
|
|
func InvRegIncBeta(a, b float64, y float64) float64 {
|
|
if y < 0 || 1 < y {
|
|
panic("mathext: parameter out of range")
|
|
}
|
|
return cephes.Incbi(a, b, y)
|
|
}
|