Skip to content

Conversation

@thibaultbl
Copy link
Contributor

Added coefficient of variation to have a relative value for standard deviation.

variation_coefficient = np.std(X) / np.mean(X)

Main problem is that we cannot compute the variable when the mean is 0, I chose to return missing value in this case.

@coveralls
Copy link

coveralls commented Apr 3, 2020

Coverage Status

Coverage increased (+0.01%) to 96.972% when pulling 6f63b08 on thibaultbl:variation_coefficient into abc6b38 on blue-yonder:master.

"""
mean = np.mean(x)
if mean != 0:
return np.std(x) / np.mean(x)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could save some computing time (even though not really needed) by using your already calculated mean here

@set_property("fctype", "simple")
def variation_coefficient(x):
"""
Returns the variation coefficient of x
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you include a short sentence on what the variant coefficient is (e.g. std / mean)?

@nils-braun
Copy link
Collaborator

Nice! Thanks for this PR! Just two very small comments

…ime of variation coefficient by reusing precomputed mean
@thibaultbl
Copy link
Contributor Author

I completed the description and added your review on code.

@nils-braun nils-braun merged commit 54de174 into blue-yonder:master Apr 5, 2020
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.

3 participants