Upstream montanaflynn/stats state of the touched files before a9577323b0
This commit is contained in:
1 parent
62beb61195
commit
f9994fd0aa
2 files changed
+1
-54
No files matched your search
+1
-13
@@ -10,9 +10,6 @@ type Quartiles struct {
|
||||
}
|
||||
|
||||
// Quartile returns the three quartile points from a slice of data
|
||||
//
|
||||
// A single value is its own lower hinge, median and upper hinge, so all
|
||||
// three quartiles are that value.
|
||||
func Quartile(input Float64Data) (Quartiles, error) {
|
||||
|
||||
il := input.Len()
|
||||
@@ -20,14 +17,6 @@ func Quartile(input Float64Data) (Quartiles, error) {
|
||||
return Quartiles{}, EmptyInputErr
|
||||
}
|
||||
|
||||
// One value is its own quartiles, which also matches what Percentile
|
||||
// returns for that value at any percent. The general path below cannot
|
||||
// produce it: the cutoffs would leave both halves empty and the two
|
||||
// hinges would come back as NaN.
|
||||
if il == 1 {
|
||||
return Quartiles{input[0], input[0], input[0]}, nil
|
||||
}
|
||||
|
||||
// Start by sorting a copy of the slice
|
||||
copy := sortedCopy(input)
|
||||
|
||||
@@ -43,8 +32,7 @@ func Quartile(input Float64Data) (Quartiles, error) {
|
||||
c2 = c1 + 1
|
||||
}
|
||||
|
||||
// Find the Medians with the cutoff points. Both halves hold at least
|
||||
// one value for every length above one, so Median cannot fail here.
|
||||
// Find the Medians with the cutoff points
|
||||
Q1, _ := Median(copy[:c1])
|
||||
Q2, _ := Median(copy)
|
||||
Q3, _ := Median(copy[c2:])
|
||||
|
||||
Reference in new issue
Block a user