import numpy as np
from typing import Union


def laplace_mech(mu: Union[float, np.ndarray], epsilon: int, sensitivity:
    float=1.0):
    """
    Implementation of the Laplace Mechanism

    Args:
      mu (float or numpy array): the true answer
      epsilon (int): the privacy budget
      sensitivity (float): the global sensitivity of the query
    """
    eps = epsilon / float(sensitivity)
    scale = 1 / eps
    np_shape = np.shape(mu)
    shape = None if np_shape == () else np_shape
    z = np.random.laplace(0.0, scale=scale, size=shape)
    return mu + z

ebec557a65c4a052f4791675e0328796d92136b6
<mask token>

<mask token>


def laplace_mech(mu: Union[float, np.ndarray], epsilon: int, sensitivity:
    float=1.0):
    """
    Implementation of the Laplace Mechanism

    Args:
      mu (float or numpy array): the true answer
      epsilon (int): the privacy budget
      sensitivity (float): the global sensitivity of the query
    """
    eps = epsilon / float(sensitivity)
    scale = 1 / eps
    np_shape = np.shape(mu)
    shape = None if np_shape == () else np_shape
    z = np.random.laplace(0.0, scale=scale, size=shape)
    return mu + z

import numpy as np
from typing import Union


def laplace_mech(mu: Union[float, np.ndarray], epsilon: int, sensitivity:
    float=1.0):
    """
    Implementation of the Laplace Mechanism

    Args:
      mu (float or numpy array): the true answer
      epsilon (int): the privacy budget
      sensitivity (float): the global sensitivity of the query
    """
    eps = epsilon / float(sensitivity)
    scale = 1 / eps
    np_shape = np.shape(mu)
    shape = None if np_shape == () else np_shape
    z = np.random.laplace(0.0, scale=scale, size=shape)
    return mu + z
