def fit_gaussian ( samples , ddof = 0 ) : if len ( samples . shape ) == 1 : return np . mean ( samples ) , np . std ( samples , ddof = ddof ) return np . mean ( samples , axis = 1 ) , np . std ( samples , axis = 1 , ddof = ddof )
python fitting 2d gaussian
Calculates the mean and the standard deviation of the given samples .
def fit_gaussian(samples, ddof=0):
    """Calculates the mean and the standard deviation of the given samples.

    Args:
        samples (ndarray): a one or two dimensional array. If one dimensional we calculate the fit using all
            values. If two dimensional, we fit the Gaussian for every set of samples over the first dimension.
        ddof (int): the difference degrees of freedom in the std calculation. See numpy.
    """
    if len(samples.shape) == 1:
        return np.mean(samples), np.std(samples, ddof=ddof)
    return np.mean(samples, axis=1), np.std(samples, axis=1, ddof=ddof)