It seems to be a problem of differential update of caste_points and accumulating rounding error.
In my case I've just got
caste_points = { 8.2156503822261584e-15, -5.1070259132757201e-14, 0, 0, 0, 0, 0, 0},
It might make sense to just sum all entry caste points for caste using https://cp-algorithms.com/data_structures/segment_tree.html, this approach would use log(N) to update signle entry, but will not accumulate errors.