INNER CODE UNIT · Python
BOCD
AlexShakaev/backtesting_and_algotrading_options_with_Interactive_Brokers_API · utils/bocd.py:44
class BOCD:
def __init__(self, hazard_function, observation_likelihood, length):
self.t = 0
self.R = np.zeros((length, length))
self.H = hazard_function
self.observation_likelihood = observation_likelihood
self.R[0, 0] = 1
self.changepoints = []
self.cp_probs = []
self.length = length
self.cp_detected = False
def expand_matrix(self):
L = self.R.shape[0]
self.R = np.pad(self.R, ((0,L),(0,L)))
self.length = self.R.shape[0]
def update(self, x):