Adding dep files and dependencies.
This commit is contained in:
parent
45f9efa578
commit
b341c0a0e4
539 changed files with 313111 additions and 0 deletions
57
vendor/github.com/montanaflynn/stats/deviation.go
generated
vendored
Normal file
57
vendor/github.com/montanaflynn/stats/deviation.go
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
package stats
|
||||
|
||||
import "math"
|
||||
|
||||
// MedianAbsoluteDeviation finds the median of the absolute deviations from the dataset median
|
||||
func MedianAbsoluteDeviation(input Float64Data) (mad float64, err error) {
|
||||
return MedianAbsoluteDeviationPopulation(input)
|
||||
}
|
||||
|
||||
// MedianAbsoluteDeviationPopulation finds the median of the absolute deviations from the population median
|
||||
func MedianAbsoluteDeviationPopulation(input Float64Data) (mad float64, err error) {
|
||||
if input.Len() == 0 {
|
||||
return math.NaN(), EmptyInput
|
||||
}
|
||||
|
||||
i := copyslice(input)
|
||||
m, _ := Median(i)
|
||||
|
||||
for key, value := range i {
|
||||
i[key] = math.Abs(value - m)
|
||||
}
|
||||
|
||||
return Median(i)
|
||||
}
|
||||
|
||||
// StandardDeviation the amount of variation in the dataset
|
||||
func StandardDeviation(input Float64Data) (sdev float64, err error) {
|
||||
return StandardDeviationPopulation(input)
|
||||
}
|
||||
|
||||
// StandardDeviationPopulation finds the amount of variation from the population
|
||||
func StandardDeviationPopulation(input Float64Data) (sdev float64, err error) {
|
||||
|
||||
if input.Len() == 0 {
|
||||
return math.NaN(), EmptyInput
|
||||
}
|
||||
|
||||
// Get the population variance
|
||||
vp, _ := PopulationVariance(input)
|
||||
|
||||
// Return the population standard deviation
|
||||
return math.Pow(vp, 0.5), nil
|
||||
}
|
||||
|
||||
// StandardDeviationSample finds the amount of variation from a sample
|
||||
func StandardDeviationSample(input Float64Data) (sdev float64, err error) {
|
||||
|
||||
if input.Len() == 0 {
|
||||
return math.NaN(), EmptyInput
|
||||
}
|
||||
|
||||
// Get the sample variance
|
||||
vs, _ := SampleVariance(input)
|
||||
|
||||
// Return the sample standard deviation
|
||||
return math.Pow(vs, 0.5), nil
|
||||
}
|
Reference in a new issue