Newer
Older
from numpy import ndarray
import numpy as np
class WeightedEstimate:
def __init__(self, λs):
self.λs = λs
def update(self, model_probabilities: ndarray) -> float:
"""
Calculate the most likely model and the weighted mass estimate.
"""
# Determine the most likely model after updating probabilities
most_likely_model_index = np.argmax(model_probabilities)
most_likely_parameter = self.λs[most_likely_model_index]
# Calculate the weighted parameter estimate
weighted_mass_estimate = np.sum([p * λ for p, λ in zip(model_probabilities, self.λs)])
return weighted_mass_estimate