def __init__(self, num_target_qubits: int, mu: float = 0, sigma: float = 1, low: float = 0, high: float = 1) -> None: r""" Univariate lognormal distribution Args: num_target_qubits: number of qubits it acts on, has a min. value of 1. mu: expected value of considered normal distribution sigma: standard deviation of considered normal distribution low: lower bound, i.e., the value corresponding to \|0...0> (assuming an equidistant grid) high: upper bound, i.e., the value corresponding to \|1...1> (assuming an equidistant grid) """ validate_min('num_target_qubits', num_target_qubits, 1) probabilities, _ = UnivariateDistribution.\ pdf_to_probabilities( lambda x: lognorm.pdf(x, s=sigma, scale=np.exp(mu)), low, high, 2 ** num_target_qubits) super().__init__(num_target_qubits, probabilities, low, high)
def __init__(self, num_target_qubits, mu=0, sigma=1, low=0, high=1): """ Constructor. Univariate lognormal distribution Args: num_target_qubits (int): number of qubits it acts on mu (float): expected value of considered normal distribution sigma (float): standard deviation of considered normal distribution low (float): lower bound, i.e., the value corresponding to |0...0> (assuming an equidistant grid) high (float): upper bound, i.e., the value corresponding to |1...1> (assuming an equidistant grid) """ self.validate(locals()) probabilities, _ = UnivariateDistribution.\ pdf_to_probabilities(lambda x: lognorm.pdf(x, s=sigma, scale=np.exp(mu)), low, high, 2 ** num_target_qubits) super().__init__(num_target_qubits, probabilities, low, high)
def lognorm_pdf(mean, sd): """Define a log-normal PDF from its mean and standard deviation""" sigma = np.sqrt(np.log(1 + sd**2 / mean**2)) mu = np.log(mean) - (sigma**2 / 2) return lambda x: lognorm.pdf(x, s=sigma, scale=np.exp(mu))
def __init__(self, num_target_qubits, mu=0, sigma=1, low=0, high=1): self.validate(locals()) probabilities, _ = UnivariateDistribution.\ pdf_to_probabilities(lambda x: lognorm.pdf(x, s=sigma, scale=np.exp(mu)), low, high, 2 ** num_target_qubits) super().__init__(num_target_qubits, probabilities, low, high)