This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,5 @@
|
||||
double mean(const double *x, long n) {
|
||||
double total = 0.0;
|
||||
for (long i = 0; i < n; i++) total += x[i];
|
||||
return total / (double)n;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
def mean(x: List[Float64]) -> Float64:
|
||||
var total: Float64 = 0.0
|
||||
for i in range(len(x)):
|
||||
total = total + x[i]
|
||||
return total / Float64(len(x))
|
||||
@@ -0,0 +1,17 @@
|
||||
def mean(x: List[Float64]) -> Float64:
|
||||
var s0: Float64 = 0.0
|
||||
var s1: Float64 = 0.0
|
||||
var s2: Float64 = 0.0
|
||||
var s3: Float64 = 0.0
|
||||
var n = len(x)
|
||||
var i = 0
|
||||
while i + 4 <= n:
|
||||
s0 = s0 + x[i]
|
||||
s1 = s1 + x[i + 1]
|
||||
s2 = s2 + x[i + 2]
|
||||
s3 = s3 + x[i + 3]
|
||||
i = i + 4
|
||||
while i < n:
|
||||
s0 = s0 + x[i]
|
||||
i = i + 1
|
||||
return ((s0 + s1) + (s2 + s3)) / Float64(n)
|
||||
@@ -0,0 +1,5 @@
|
||||
import math
|
||||
|
||||
|
||||
def mean(x):
|
||||
return math.fsum(x) / len(x)
|
||||
@@ -0,0 +1,5 @@
|
||||
def mean(x):
|
||||
total = 0.0
|
||||
for v in x:
|
||||
total += v
|
||||
return total / len(x)
|
||||
Reference in new issue
Block a user