Skip to content

Adding Median absolute deviation, #4 #24

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thomasfoster
Copy link
Contributor

No description provided.

@@ -332,6 +333,7 @@ These methods compute a measure of the variability in a sample or population, ho
- [pStdev](#pStdev): Population standard deviation
- [variance](#variance): Sample variance
- [stdev](#stdev): Sample standard deviation
- [medAbsdev](#medAbsdev): Median absolute deviation
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please rename this method to mad throughout all files?

export function medAbsdev(arr) {
const med = median(arr);
const absoluteDeviationArr = [];
if (med === undefined) return undefined;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can go above the previous line. It is not necessary to declare absoluteDeviationArr before checking if the median is undefined.

const absoluteDeviationArr = [];
if (med === undefined) return undefined;
for (let i = 0; i < arr.length; i += 1) {
const absdev = Math.abs(arr[i] - med);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be consistent with variable naming and use camelCase. Following the previously defined array absoluteDeviationArr this would be absoluteDeviation.

In this case, absoluteDeviationArr could even be renamed to absoluteDeviations. I leave this to your discretion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants