summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/statisticsFunctions/moment/dmoments.c
diff options
context:
space:
mode:
Diffstat (limited to '2.3-1/src/c/statisticsFunctions/moment/dmoments.c')
-rw-r--r--2.3-1/src/c/statisticsFunctions/moment/dmoments.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/2.3-1/src/c/statisticsFunctions/moment/dmoments.c b/2.3-1/src/c/statisticsFunctions/moment/dmoments.c
new file mode 100644
index 00000000..b9d8564a
--- /dev/null
+++ b/2.3-1/src/c/statisticsFunctions/moment/dmoments.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "moment.h"
+
+
+double dmoments (double* inp, int size, double ord)
+{
+ double sum = 0;
+
+ for(int i = 0; i < size; i++)
+ {
+ sum = sum + pow(inp[i], ord);
+ }
+
+ return sum/size;
+}