summaryrefslogtreecommitdiff
path: root/src/c/statisticsFunctions/moment/smoments.c
blob: c900d81589809446ce963ddc559728e4bcff6407 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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;
}