Fixed bug related to anomaly detection system
This commit is contained in:
@@ -19,12 +19,11 @@ Zephyr is designed to be simple, fast and efficient, providing only the
|
||||
weather data of a given location, without any additional nonsense.
|
||||
|
||||
This service communicates through a JSON API, making it suitable for
|
||||
any kind of internet-based project or device. I already use it on a widget
|
||||
on my phone, on my terminal, on the tmux's status bar, in a couple of
|
||||
smart bedside clocks I've built and as a standalone web app.
|
||||
any kind of internet-based project or device. I already use it as a [standalone web app](https://m.marcocetica.com),
|
||||
as a phone widget and on my terminal.
|
||||
|
||||
## Weather
|
||||
As state before, Zephyr talks via HTTP using the JSON format. Therefore, you
|
||||
As stated before, Zephyr talks via HTTP using JSON formatting. Therefore, you
|
||||
can query it using any HTTP client of your choice. Below you can find some examples
|
||||
using `curl`:
|
||||
|
||||
|
||||
@@ -45,14 +45,17 @@ func Median(temperatures []float64) float64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
slices.Sort(temperatures)
|
||||
length := len(temperatures)
|
||||
// Sort the array without mutating the original values
|
||||
sortedTemps := slices.Clone(temperatures)
|
||||
slices.Sort(sortedTemps)
|
||||
|
||||
length := len(sortedTemps)
|
||||
midValue := length / 2
|
||||
|
||||
if length%2 == 0 {
|
||||
return (temperatures[midValue-1] + temperatures[midValue]) / 2
|
||||
return (sortedTemps[midValue-1] + sortedTemps[midValue]) / 2
|
||||
} else {
|
||||
return temperatures[midValue]
|
||||
return sortedTemps[midValue]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,10 +66,12 @@ func Mode(temperatures []float64) float64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
slices.Sort(temperatures)
|
||||
// Sort the array without mutating the original values
|
||||
sortedTemps := slices.Clone(temperatures)
|
||||
slices.Sort(sortedTemps)
|
||||
|
||||
frequencies := make(map[float64]int)
|
||||
for _, val := range temperatures {
|
||||
for _, val := range sortedTemps {
|
||||
frequencies[val]++
|
||||
}
|
||||
|
||||
@@ -124,6 +129,7 @@ func RobustZScore(temperatures []float64) []struct {
|
||||
Idx int
|
||||
Value float64
|
||||
}
|
||||
|
||||
for idx, val := range temperatures {
|
||||
z := scale * (val - med) / madAbsDev
|
||||
|
||||
|
||||
Reference in New Issue
Block a user