| | |
| | | #include <string.h> |
| | | #include <math.h> |
| | | |
| | | float sec(clock_t clocks) |
| | | { |
| | | return (float)clocks/CLOCKS_PER_SEC; |
| | | } |
| | | |
| | | void error(char *s) |
| | | { |
| | | fprintf(stderr, "Error: %s\n", s); |
| | |
| | | return field; |
| | | } |
| | | |
| | | float mean_array(float *a, int n) |
| | | float sum_array(float *a, int n) |
| | | { |
| | | int i; |
| | | float sum = 0; |
| | | for(i = 0; i < n; ++i) sum += a[i]; |
| | | return sum/n; |
| | | return sum; |
| | | } |
| | | |
| | | float mean_array(float *a, int n) |
| | | { |
| | | return sum_array(a,n)/n; |
| | | } |
| | | |
| | | float variance_array(float *a, int n) |
| | |
| | | for(i = 0; i < 12; ++i) sum += (float)rand()/RAND_MAX; |
| | | return sum-6.; |
| | | } |
| | | float rand_uniform() |
| | | { |
| | | return (float)rand()/RAND_MAX; |
| | | } |
| | | |
| | | float **one_hot_encode(float *a, int n, int k) |
| | | { |