I have a list of numbers and I am trying to detect a drastic point difference from the previous numbers and see if the pattern has changed. For instance,
x = [5000,5500,6250,4800,3950,7200,5500,800,1200,900,500,400,300,200]
Above, there is high spending until 800 and then it seems that there is high spending before the 800 and low spending after the 800. All in all after 800, the spending has decreased a good bit. I want to try and divide the list based on this drastic point and then check if there is a different pattern (i.e. there is high spending before and low spending after or if there is low spending before and low spending after or low spending before high spending after or high spending before and high spending after). Essentially, I am looking for this sort of inflection point and trying to detect if there are two different classes of numbers. I know I could set a threshold and check each number or assume a normal distribution and check standard deviations. Is there a better way to approach this problem from a more statistical point of view? Note that the numbers could be of larger scale, purchases could be tens of thousands of dollars and then drop to thousands of dollars and this should indicate a change. I'm wondering if there is some statistical based method that is better than using standard deviations and means.
For a set of numbers like x above the following does not work well
def reject_outliers(data, m = 2.): d = np.abs(data - np.median(data)) mdev = np.median(d) s = d/mdev if mdev else 0. return data[s<m]