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))
Exemple #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))
Exemple #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)
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)
Exemple #5
0
def median(a: ndarray,
           axis: tp.Optional[int] = None) \
        -> tp.Union[numbers.Number, ndarray]:
    """
    Compute the median along the specified axis.
    """

    new_af_array = af.median(a._af_array, dim=axis)
    if isinstance(new_af_array, af.Array):
        return ndarray(new_af_array)
    else:
        return new_af_array
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))
print(af.median(w))

print(af.corrcoef(a, b))
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))