Skip to content

Instantly share code, notes, and snippets.

@simonbromberg
Last active May 26, 2016 16:09
Show Gist options
  • Save simonbromberg/5c6d9dbb39d72cede37ba20703499791 to your computer and use it in GitHub Desktop.
Save simonbromberg/5c6d9dbb39d72cede37ba20703499791 to your computer and use it in GitHub Desktop.
Calculate histogram data
- (void)getMax:(float *)max min:(float *)min on:(NSArray *)arr {
for (NSNumber *num in arr) {
*max = MAX(*max, num.floatValue);
*min = MIN(*min, num.floatValue);
}
}
- (int)indexForResponse:(float)response max:(float)max min:(float)min bucketCount:(int)count {
float bucketWidth = (max - min) / count;
return floorf((response - min) / bucketWidth);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment