瀏覽代碼

Include missing header and fix stddev

Standard deviation on a non complete population sample is divided by n-1, not n
v2
Xerbo 1 年之前
父節點
當前提交
c551e70335
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 34103F6D8F11CEB0
共有 2 個檔案被更改,包括 4 行新增6 行删除
  1. +3
    -6
      libaptdec/algebra.c
  2. +1
    -0
      libaptdec/effects.c

+ 3
- 6
libaptdec/algebra.c 查看文件

@@ -52,12 +52,9 @@ linear_t linear_regression(const float *independent, const float *dependent, siz
return (linear_t){a, b};
}

// "Sample" standard deviation
float standard_deviation(const float *data, size_t len) {
float mean = 0.0f;
for (size_t i = 0; i < len; i++) {
mean += data[i];
}
mean /= (float)len;
float mean = meanf(data, len);

float deviation_mean = 0.0f;
for (size_t i = 0; i < len; i++) {
@@ -65,7 +62,7 @@ float standard_deviation(const float *data, size_t len) {
deviation_mean += deviation * deviation;
}

return sqrtf(deviation_mean / (float)len);
return sqrtf(deviation_mean / (float)(len-1));
}

float sumf(const float *x, size_t len) {


+ 1
- 0
libaptdec/effects.c 查看文件

@@ -20,6 +20,7 @@
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#include "algebra.h"
#include "util.h"


Loading…
取消
儲存