(x_gpu, ddof=0, axis=None, stream=None, keepdims=False)
return out
Compute the variance along the specified axis.

    Returns the variance of the array elements, a measure of the spread of a
    distribution. The variance is computed for the flattened array by default,
    otherwise over the specified axis.

    Parameters
    ----------
    x_gpu : pycuda.gpuarray.GPUArray
        Array containing numbers whose variance is desired.
    ddof : int (optional)
        "Delta Degrees of Freedom": the divisor used in computing the 
        variance is ``N - ddof``, where ``N`` is the number of elements.
        Setting ``ddof = 1`` is equivalent to applying Bessel's
        correction.
    axis : int (optional)
        Axis along which the variance are computed. The default is to
        compute the variance of the flattened array.
    stream : pycuda.driver.Stream (optional)
        Optional CUDA stream in which to perform this calculation
    keepdims : bool (optional, default False)
        If True, the axes which are reduced are left in the result as
        dimensions with size one.

    Returns
    -------
    out : pycuda.gpuarray.GPUArray
        variance of elements, or variances of elements along the desired axis.
Compute the variance along the specified axis.
Compute the variance along the specified axis .
def var(x_gpu, ddof=0, axis=None, stream=None, keepdims=False):
    """
    Compute the variance along the specified axis.

    Returns the variance of the array elements, a measure of the spread of a
    distribution. The variance is computed for the flattened array by default,
    otherwise over the specified axis.

    Parameters
    ----------
    x_gpu : pycuda.gpuarray.GPUArray
        Array containing numbers whose variance is desired.
    ddof : int (optional)
        "Delta Degrees of Freedom": the divisor used in computing the 
        variance is ``N - ddof``, where ``N`` is the number of elements.
        Setting ``ddof = 1`` is equivalent to applying Bessel's
        correction.
    axis : int (optional)
        Axis along which the variance are computed. The default is to
        compute the variance of the flattened array.
    stream : pycuda.driver.Stream (optional)
        Optional CUDA stream in which to perform this calculation
    keepdims : bool (optional, default False)
        If True, the axes which are reduced are left in the result as
        dimensions with size one.

    Returns
    -------
    out : pycuda.gpuarray.GPUArray
        variance of elements, or variances of elements along the desired axis.
    """
    def _inplace_pow(x_gpu, p, stream):
        func = elementwise.get_pow_kernel(x_gpu.dtype)
        func.prepared_async_call(x_gpu._grid, x_gpu._block, stream,
                    p, x_gpu.gpudata, x_gpu.gpudata, x_gpu.mem_size)

    if axis is None:
        m = mean(x_gpu).get()
        out = x_gpu - m
        out **= 2
        out = _sum_axis(out, axis=None, calc_mean=True,
                        ddof=ddof, out=None, keepdims=keepdims)
    else:
        if axis < 0:
            axis += 2
        m = mean(x_gpu, axis=axis)
        out = add_matvec(x_gpu, -m, axis=1-axis, stream=stream)
        _inplace_pow(out, 2, stream)
        out = _sum_axis(out, axis=axis, calc_mean=True,
                        ddof=ddof, out=None, keepdims=keepdims)
    return out
def var ( x_gpu , ddof = 0 , axis = None , stream = None , keepdims = False ) : def _inplace_pow ( x_gpu , p , stream ) : func = elementwise . get_pow_kernel ( x_gpu . dtype ) func . prepared_async_call ( x_gpu . _grid , x_gpu . _block , stream , p , x_gpu . gpudata , x_gpu . gpudata , x_gpu . mem_size ) if axis is None : m = mean ( x_gpu ) . get ( ) out = x_gpu - m out **= 2 out = _sum_axis ( out , axis = None , calc_mean = True , ddof = ddof , out = None , keepdims = keepdims ) else : if axis < 0 : axis += 2 m = mean ( x_gpu , axis = axis ) out = add_matvec ( x_gpu , - m , axis = 1 - axis , stream = stream ) _inplace_pow ( out , 2 , stream ) out = _sum_axis ( out , axis = axis , calc_mean = True , ddof = ddof , out = None , keepdims = keepdims ) return out