mirror of
https://github.com/gonum/gonum.git
synced 2025-10-05 07:06:54 +08:00
32 lines
970 B
Go
32 lines
970 B
Go
// Copyright ©2015 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 distmv provides multivariate random distribution types.
|
|
package distmv // import "gonum.org/v1/gonum/stat/distmv"
|
|
|
|
var (
|
|
badQuantile = "distmv: quantile not between 0 and 1"
|
|
badReceiver = "distmv: input slice is not nil or the correct length"
|
|
badSizeMismatch = "distmv: size mismatch"
|
|
badZeroDimension = "distmv: zero dimensional input"
|
|
nonPosDimension = "distmv: non-positive dimension input"
|
|
)
|
|
|
|
const logTwoPi = 1.8378770664093454835606594728112352797227949472755668
|
|
|
|
// useAs gets a slice of size n. If len(x) == n, x is returned, if len(x) == 0
|
|
// then a slice is returned of length n.
|
|
func reuseAs(x []float64, n int) []float64 {
|
|
if len(x) == n {
|
|
return x
|
|
}
|
|
if len(x) == 0 {
|
|
if cap(x) >= n {
|
|
return x[:n]
|
|
}
|
|
return make([]float64, n)
|
|
}
|
|
panic(badReceiver)
|
|
}
|