Example #1
0
func ExampleQuantileFromSortedData() {
	data := statistics.Float64{17.2, 18.1, 16.5, 18.3, 12.6}
	sort.Sort(&data)
	upperq := statistics.QuantileFromSortedData(&data, 0.75)
	lowerq := statistics.QuantileFromSortedData(&data, 0.25)

	fmt.Printf("Sorted dataset: %v\n", data)
	fmt.Printf("The upper quartile is %g\n", upperq)
	fmt.Printf("The lower quartile is %g\n", lowerq)
	// Output:
	// Sorted dataset: [12.6 16.5 17.2 18.1 18.3]
	// The upper quartile is 18.1
	// The lower quartile is 16.5
}
Example #2
0
// Find the dates where a given wiki page experienced abnormally high
// activity
func FindDates(wr *WikiResponse, viewPercentile float64) (dates map[string]int) {
	vals := GetValuesFromMap(wr.Yearly)
	sort.Sort(vals)
	result := statistics.QuantileFromSortedData(vals, viewPercentile)
	dates = GetKeysGE(wr.Yearly, result)
	return
}
Example #3
0
// Find the companies with the highest number of mean views according to a
// mean view percentile
func FindHighestMeans(means map[string]int, meanPercentile float64) (stats map[string]int) {
	vals := GetValuesFromMap(means)
	result := statistics.QuantileFromSortedData(vals, meanPercentile)
	stats = GetKeysGE(means, result)
	return
}