30 days of code in Go: Day 17 - Standard Deviation
Hi there! Today’s challenge was to compute standard deviation of an array of data given the formula $$\sigma = \sqrt{\frac{\sum_{i=0}^{N-1} (x_i - \mu)^2}{N}},$$ where $$\mu = \frac{\sum_{i=0}^{N-1} x_i}{N}.$$ The first input to the program is N and then N integers are fed to the program in sequence. My solution is given below. package main import ( "fmt" "math" ) func mean(a []int) float64 { n := float64(len(a)) sum := 0.0 for i := 0; i < len(a); i++ { sum += float64(a[i]) } return sum / n } func sigma(a []int) float64 { mu := mean(a) sum := 0....