I am trying to reproduce the bimodalSample function of this blog in Python.
My attempt:
import numpy as npdef bimodal_pdf(distance: float, weight: float) -> np.ndarray: r = np.random.rand() if r < weight: return np.random.normal(r) * (1 - distance) else: return np.random.normal(r) * (1 - distance) + distancen_samples = 100000distance = 0.7weight = 0.5pdf = np.array([ bimodal_pdf(distance=distance, weight=weight) for s in range(n_samples)])However, I am getting values below zero and above 1. What's wrong with my implementation?Thanks