Skip to content

Instantly share code, notes, and snippets.

@photodude
Last active January 15, 2022 23:52
Show Gist options
  • Save photodude/6c7fab9c03f7abc690605ce3226cb418 to your computer and use it in GitHub Desktop.
Save photodude/6c7fab9c03f7abc690605ce3226cb418 to your computer and use it in GitHub Desktop.
std_deviation with warning
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