-
Notifications
You must be signed in to change notification settings - Fork 115
Statistic Module added #243
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
Changes from 3 commits
d7d95a2
adcd925
063e7bd
f637c05
bdd4339
2239320
2a76ba2
c3aea80
72a910b
acc73da
a2c97bf
d83d48b
009a8cd
b130a04
9962331
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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,151 @@ | ||||||||||||||
| ### statistics | ||||||||||||||
|
|
||||||||||||||
| > Statisctics Functions. <a href="docs/underscore.collections.statistics.js.html" class="btn btn-primary btn-xs">View Annotated Source</a> | ||||||||||||||
| #### mean | ||||||||||||||
|
|
||||||||||||||
| Signature: `_.mean(... arrays:Array ...)` | ||||||||||||||
|
|
||||||||||||||
| The `_.mean` function finds out the average value from the array of numbers. | ||||||||||||||
|
|
||||||||||||||
| ```javascript | ||||||||||||||
|
|
||||||||||||||
| _.mean([]); | ||||||||||||||
| //=> 0 | ||||||||||||||
|
|
||||||||||||||
| _.mean([0, 1, 2, 3, 4]); | ||||||||||||||
| //=> 2 | ||||||||||||||
|
|
||||||||||||||
| _.mean(null) | ||||||||||||||
| //=> 0 | ||||||||||||||
|
|
||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| #### median | ||||||||||||||
|
|
||||||||||||||
| Signature: `_.median(... arrays:Array ...)` | ||||||||||||||
|
|
||||||||||||||
| The `_.median` function finds out the middle value from the array of numbers. | ||||||||||||||
|
|
||||||||||||||
| Calulation of median is done using the following method. | ||||||||||||||
|
|
||||||||||||||
| If the array has odd numbers then median is the middle element. | ||||||||||||||
|
|
||||||||||||||
| If the array has even numbers then average of middle two numbers is the median value. | ||||||||||||||
|
||||||||||||||
| If the array has odd numbers then median is the middle element. | |
| If the array has even numbers then average of middle two numbers is the median value. | |
| If the array has odd length then median is the middle element. | |
| If the array has even length then average of middle two numbers is the median value. |
Outdated
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 presume it sums a single array.
| The `_.sum` function calculates the sum of the given arrays. | |
| The `_.sum` function calculates the sum of the given array. |
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.
Perhaps add a link here to the Wikipedia entry that explains the variance. Likewise for the other statistical concepts that follow.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,7 +9,7 @@ export default function variance(collection, iteratee, context) { | |||||
| if (typeof iteratee == 'number' && collection != null && typeof collection[0] != 'object') { | ||||||
| iteratee = null; | ||||||
| } | ||||||
| iteratee = cb(iteratee, context); | ||||||
| iteratee = iteratee(iteratee, context); | ||||||
|
||||||
| iteratee = iteratee(iteratee, context); | |
| iteratee = _.iteratee(iteratee, context); |
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.
Is it really
arrays, plural?