コード例 #1
0
def simple_statistics(verbose=False):
    display_func = _util.display_func(verbose)
    print_func = _util.print_func(verbose)

    a = af.randu(5, 5)
    b = af.randu(5, 5)
    w = af.randu(5, 1)

    display_func(af.mean(a, dim=0))
    display_func(af.mean(a, weights=w, dim=0))
    print_func(af.mean(a))
    print_func(af.mean(a, weights=w))

    display_func(af.var(a, dim=0))
    display_func(af.var(a, isbiased=True, dim=0))
    display_func(af.var(a, weights=w, dim=0))
    print_func(af.var(a))
    print_func(af.var(a, isbiased=True))
    print_func(af.var(a, weights=w))

    display_func(af.stdev(a, dim=0))
    print_func(af.stdev(a))

    display_func(af.var(a, dim=0))
    display_func(af.var(a, isbiased=True, dim=0))
    print_func(af.var(a))
    print_func(af.var(a, isbiased=True))

    display_func(af.median(a, dim=0))
    print_func(af.median(w))

    print_func(af.corrcoef(a, b))
コード例 #2
0
def simple_statistics(verbose=False):
    display_func = _util.display_func(verbose)
    print_func   = _util.print_func(verbose)

    a = af.randu(5, 5)
    b = af.randu(5, 5)
    w = af.randu(5, 1)

    display_func(af.mean(a, dim=0))
    display_func(af.mean(a, weights=w, dim=0))
    print_func(af.mean(a))
    print_func(af.mean(a, weights=w))

    display_func(af.var(a, dim=0))
    display_func(af.var(a, isbiased=True, dim=0))
    display_func(af.var(a, weights=w, dim=0))
    print_func(af.var(a))
    print_func(af.var(a, isbiased=True))
    print_func(af.var(a, weights=w))

    display_func(af.stdev(a, dim=0))
    print_func(af.stdev(a))

    display_func(af.var(a, dim=0))
    display_func(af.var(a, isbiased=True, dim=0))
    print_func(af.var(a))
    print_func(af.var(a, isbiased=True))

    display_func(af.median(a, dim=0))
    print_func(af.median(w))

    print_func(af.corrcoef(a, b))
コード例 #3
0
def simple_statistics(verbose=False):
    display_func = _util.display_func(verbose)
    print_func = _util.print_func(verbose)

    a = af.randu(5, 5)
    b = af.randu(5, 5)
    w = af.randu(5, 1)

    display_func(af.mean(a, dim=0))
    display_func(af.mean(a, weights=w, dim=0))
    print_func(af.mean(a))
    print_func(af.mean(a, weights=w))

    display_func(af.var(a, dim=0))
    display_func(af.var(a, isbiased=True, dim=0))
    display_func(af.var(a, weights=w, dim=0))
    print_func(af.var(a))
    print_func(af.var(a, isbiased=True))
    print_func(af.var(a, weights=w))

    mean, var = af.meanvar(a, dim=0)
    display_func(mean)
    display_func(var)
    mean, var = af.meanvar(a, weights=w, bias=af.VARIANCE.SAMPLE, dim=0)
    display_func(mean)
    display_func(var)

    display_func(af.stdev(a, dim=0))
    print_func(af.stdev(a))

    display_func(af.var(a, dim=0))
    display_func(af.var(a, isbiased=True, dim=0))
    print_func(af.var(a))
    print_func(af.var(a, isbiased=True))

    display_func(af.median(a, dim=0))
    print_func(af.median(w))

    print_func(af.corrcoef(a, b))

    data = af.iota(5, 3)
    k = 3
    dim = 0
    order = af.TOPK.DEFAULT  # defaults to af.TOPK.MAX
    assert (dim == 0)  # topk currently supports first dim only
    values, indices = af.topk(data, k, dim, order)
    display_func(values)
    display_func(indices)
コード例 #4
0
ファイル: _array.py プロジェクト: eeeedgar/model_1
def var(a: ndarray,
        axis: tp.Optional[int] = None,
        dtype: tp.Optional[np.generic] = None,
        out: tp.Optional[ndarray] = None,
        ddof: int = 0,
        keepdims: bool = False) -> tp.Union[float, ndarray]:
    """
    Compute the variance along the specified axis.
    """

    isbiased = True
    if ddof is not None:
        if ddof == 1:
            isbiased = False
        elif ddof == 0:
            pass
        else:
            raise ValueError(f"ddof must be 0 or 1, ddof={ddof} is not "
                             f"supported")

    new_af_array \
        = af.var(a._af_array, isbiased=isbiased, weights=None, dim=axis)

    if isinstance(new_af_array, af.Array):
        return ndarray(new_af_array)
    else:
        return new_af_array
コード例 #5
0
def simple_statistics(verbose=False):
    display_func = _util.display_func(verbose)
    print_func   = _util.print_func(verbose)

    a = af.randu(5, 5)
    b = af.randu(5, 5)
    w = af.randu(5, 1)

    display_func(af.mean(a, dim=0))
    display_func(af.mean(a, weights=w, dim=0))
    print_func(af.mean(a))
    print_func(af.mean(a, weights=w))

    display_func(af.var(a, dim=0))
    display_func(af.var(a, isbiased=True, dim=0))
    display_func(af.var(a, weights=w, dim=0))
    print_func(af.var(a))
    print_func(af.var(a, isbiased=True))
    print_func(af.var(a, weights=w))

    display_func(af.stdev(a, dim=0))
    print_func(af.stdev(a))

    display_func(af.var(a, dim=0))
    display_func(af.var(a, isbiased=True, dim=0))
    print_func(af.var(a))
    print_func(af.var(a, isbiased=True))

    display_func(af.median(a, dim=0))
    print_func(af.median(w))

    print_func(af.corrcoef(a, b))

    data = af.iota(5, 3)
    k = 3
    dim = 0
    order = af.TOPK.DEFAULT # defaults to af.TOPK.MAX
    assert(dim == 0) # topk currently supports first dim only
    values,indices = af.topk(data, k, dim, order)
    display_func(values)
    display_func(indices)
コード例 #6
0
ファイル: _array.py プロジェクト: eeeedgar/model_1
def std(a: ndarray, axis: tp.Optional[int] = None, ddof: int = 0) \
        -> tp.Union[ndarray, numbers.Number]:
    """
    Compute the standard deviation along the specified axis.
    """

    new_af_array: tp.Optional[tp.Union[ndarray, numbers.Number]] = None
    if ddof or ddof == 0:
        new_af_array = af.stdev(a._af_array, dim=axis)
    elif ddof == 1:
        new_af_array = af.sqrt(af.var(a._af_array, isbiased=False, dim=axis))
    if isinstance(new_af_array, af.Array):
        return ndarray(new_af_array)
    else:
        return new_af_array
コード例 #7
0
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################

import arrayfire as af

a = af.randu(5, 5)
b = af.randu(5, 5)
w = af.randu(5, 1)

af.display(af.mean(a, dim=0))
af.display(af.mean(a, weights=w, dim=0))
print(af.mean(a))
print(af.mean(a, weights=w))

af.display(af.var(a, dim=0))
af.display(af.var(a, isbiased=True, dim=0))
af.display(af.var(a, weights=w, dim=0))
print(af.var(a))
print(af.var(a, isbiased=True))
print(af.var(a, weights=w))

af.display(af.stdev(a, dim=0))
print(af.stdev(a))

af.display(af.var(a, dim=0))
af.display(af.var(a, isbiased=True, dim=0))
print(af.var(a))
print(af.var(a, isbiased=True))

af.display(af.median(a, dim=0))
コード例 #8
0
#!/usr/bin/python
import arrayfire as af

a = af.randu(5, 5)
b = af.randu(5, 5)
w = af.randu(5, 1)

af.print_array(af.mean(a, dim=0))
af.print_array(af.mean(a, weights=w, dim=0))
print(af.mean(a))
print(af.mean(a, weights=w))

af.print_array(af.var(a, dim=0))
af.print_array(af.var(a, isbiased=True, dim=0))
af.print_array(af.var(a, weights=w, dim=0))
print(af.var(a))
print(af.var(a, isbiased=True))
print(af.var(a, weights=w))

af.print_array(af.stdev(a, dim=0))
print(af.stdev(a))

af.print_array(af.var(a, dim=0))
af.print_array(af.var(a, isbiased=True, dim=0))
print(af.var(a))
print(af.var(a, isbiased=True))

af.print_array(af.median(a, dim=0))
print(af.median(w))

print(af.corrcoef(a, b))