-
Notifications
You must be signed in to change notification settings - Fork 0
Add in implementation of standard deviation on data #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,3 +31,14 @@ def daily_max(data): | |
| def daily_min(data): | ||
| """Calculate the daily min of a 2d inflammation data array.""" | ||
| return np.min(data, axis=0) | ||
|
|
||
|
|
||
| def s_dev(data): | ||
| """Computes and returns standard deviation for data.""" | ||
| number = np.mean(data, axis=0) | ||
| devs = [] | ||
| for entry in data: | ||
| devs.append((entry - number) * (entry - number)) | ||
|
|
||
| s_dev2 = sum(devs) / len(data) | ||
|
Comment on lines
+38
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an implementation of standard deviation from the ground up. We could probably replace with a call to |
||
| return {'standard deviation': s_dev2} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning a dict doesn't match what is returned for all of the other functions in this module. We should probably switch to just returning the calculated value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And it mixes in responsibilites that should be with the view |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't immediately know what the purpose of the
numbervariable is from its name. Based on its assignment, it is the mean along one axis, so perhaps it should be calleddata_meanor event justmean?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved by using
np.std