Skip to content

Instantly share code, notes, and snippets.

@Sleepingwell
Created May 6, 2016 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sleepingwell/65736198fe13eaf38f977c3aba018879 to your computer and use it in GitHub Desktop.
Save Sleepingwell/65736198fe13eaf38f977c3aba018879 to your computer and use it in GitHub Desktop.
Very basic empirical distribution (for unordered data).
#include "stdafx.h"
#include "emperical_dist.h"
void emperical_dist(double* vals, double* res, int* vlen, int* dlen) {
int i, j, tmp, n = *vlen;
double *valsAt, val;
for(i=0; i<*dlen; ++i, ++res){
valsAt = vals;
val = *res;
tmp = 0;
for(j=0; j<n; ++j, ++valsAt) if(*valsAt <= val) ++tmp;
*res = (double)tmp / (double)n;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment