Last active
January 15, 2022 23:52
-
-
Save photodude/6c7fab9c03f7abc690605ce3226cb418 to your computer and use it in GitHub Desktop.
std_deviation with warning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
import math | |
class valueConverter: | |
@staticmethod | |
def std_deviation(Values, format=True): | |
result = numpy.std(Values) | |
average = numpy.mean(Values) | |
for value in Values: | |
if not math.isclose(value, average, abs_tol=0.1): # individual numbers should differ by less than 0.1 from any other number | |
if format: | |
return f'standard deviation = {result:.3f} \n warning individual values >= 0.1 from mean' | |
if format: | |
return f'standard deviation = {result:.3f}' | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment