There is a post about broken rounding . However it is not a rounding problem here because it does round in the normal case as you see but it doesn't round when inserting into an array.
I have following code:
print(round(limits[1],1))
limit = [round(limits[0],1), round(limits[1],1)]
print(limit)
Output:
25860.4
[14766.4, 25860.400000000001]
I do not understand why second element of an array is not rounded, although I do round it before while I pack it into the array.
Code:
import numpy as np
def intrvl_comparison(data):
m = np.mean(data)
sd = np.std(data)
up_l = (m + sd)
low_l = (m - sd)
limits = [low_l, up_l]
limit = [round(x,1) for x in limits]
print(round(limits[0],1))
limit = [round(limits[0],1), round(limits[1],1)]
print(limit)
intrvl_comparison([2.66666,4.4444444,6066,9999])