summaryrefslogtreecommitdiff
path: root/src/c/statisticsFunctions/moment/smoments.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/statisticsFunctions/moment/smoments.c')
-rw-r--r--src/c/statisticsFunctions/moment/smoments.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/c/statisticsFunctions/moment/smoments.c b/src/c/statisticsFunctions/moment/smoments.c
new file mode 100644
index 00000000..c900d815
--- /dev/null
+++ b/src/c/statisticsFunctions/moment/smoments.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "moment.h"
+
+
+float smoments (float* inp, int size, double ord)
+{
+ float sum = 0;
+
+ for(int i = 0; i < size; i++) // Elements are raised to the order and then their mean is calculated to give moment
+ {
+ sum = sum + pow(inp[i], ord);
+ }
+
+ return sum/size;
+}