package main import ( "container/list" "fmt" "math/rand" "strings" "time" ) const ( letterIdxBits = 6 letterIdxMask = 1<= 0; { if remain == 0 { cache, remain = rand.Int63(), letterIdxMax } if idx := int(cache & letterIdxMask); idx < len(letterBytes) { b[i] = letterBytes[idx] i-- } cache >>= letterIdxBits remain-- } return string(b) } func generateRandomIPAddress() string { rand.Seed(time.Now().Unix()) ip := fmt.Sprintf("%d.%d.%d.%d", rand.Intn(255), rand.Intn(255), rand.Intn(255), rand.Intn(255)) return ip } func LeastSquares(x []float64, y []float64) (a float64, b float64) { xi := float64(0) x2 := float64(0) yi := float64(0) xy := float64(0) if len(x) != len(y) { a = 0 b = 0 return } else { length := float64(len(x)) for i := 0; i < len(x); i++ { xi += x[i] x2 += x[i] * x[i] yi += y[i] xy += x[i] * y[i] } a = (yi*xi - xy*length) / (xi*xi - x2*length) b = (yi*x2 - xy*xi) / (x2*length - xi*xi) } return }