INNER CODE UNIT · Python
H
AlexShakaev/backtesting_and_algotrading_options_with_Interactive_Brokers_API · utils/bocd.py:71
H = self.H(np.array(range(t + 1)))
# Evaluate the growth probabilities - shift the probabilities down and to
# the right, scaled by the hazard function and the predictive
# probabilities.
self.R[1 : t + 2, t + 1] = self.R[0 : t + 1, t] * predprobs * (1 - H)
# Evaluate the probability that there *was* a changepoint and we're
# accumulating the mass back down at r = 0.
self.R[0, t + 1] = np.sum(self.R[0 : t + 1, t] * predprobs * H)
# Renormalize the run length probabilities for improved numerical
# stability.
self.R[:, t + 1] = self.R[:, t + 1] / np.sum(self.R[:, t + 1])
# Update the parameter sets for each possible run length.
self.observation_likelihood.update_theta(x)