Created
December 5, 2011 22:40
-
-
Save chrisgilmerproj/1435738 to your computer and use it in GitHub Desktop.
Simple mode code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float mode(float *data_array){ | |
int c_new, c_old = 0, 0; | |
float mode_new, mode_old = 0.0, 0.0; | |
int i; | |
for(i = 0; i < len(data_array); i++){ | |
float num = data_array[i] | |
if (num != mode_new) { | |
if (c_new > c_old) { | |
c_old = c_new; | |
mode_old = mode_new; | |
c_new = 0; | |
} | |
mode_new = num; | |
} | |
c_new++; | |
} | |
return mode_old; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment