bayespy.utils.misc

General numerical functions and methods.

Functions

T(X)

Transpose the matrix.

add_axes(X[, num, axis])

add_leading_axes(x, n)

add_trailing_axes(x, n)

array_to_scalar(x)

atleast_nd(X, d)

axes_to_collapse(shape_x, shape_to)

block_banded(D, B)

Construct a symmetric block-banded matrix.

block_diag(*arrays)

Form a block diagonal array from the given arrays.

broadcast(*arrays[, ignore_axis])

Explicitly broadcast arrays to same shapes.

broadcasted_shape(*shapes)

Computes the resulting broadcasted shape for a given set of shapes.

broadcasted_shape_from_arrays(*arrays)

Computes the resulting broadcasted shape for a given set of arrays.

broadcasting_multiplier(plates, *args)

Compute the plate multiplier for given shapes.

ceildiv(a, b)

Compute a divided by b and rounded up.

composite_function(function_list)

Construct a function composition from a list of functions.

concatenate(*arrays[, axis])

Concatenate arrays along a given axis.

diag(X[, ndim])

Create a diagonal array given the diagonal elements.

diagonal(A)

dist_haversine(c1, c2[, radius])

find_set_index(index, set_lengths)

Given set sizes and an index, returns the index of the set

first(L)

flatten_axes(X, *ndims)

gaussian_logpdf(y_invcov_y, y_invcov_mu, ...)

get_diag(X[, ndim, ndim_to])

Get the diagonal of an array.

gradient(f, x[, epsilon])

grid(x1, x2)

Returns meshgrid as a (M*N,2)-shape array.

identity(*shape)

invgamma(x)

Inverse gamma function.

invpsi(x)

Inverse digamma (psi) function.

is_callable(f)

is_numeric(a)

is_scalar_integer(x)

is_shape_subset(sub_shape, full_shape)

is_string(s)

isinteger(x)

logsumexp(X[, axis, keepdims])

Compute log(sum(exp(X)) in a numerically stable way

m_digamma(a, d)

Returns the derivative of the log of multivariate gamma.

m_dot(A, b)

make_diag(X[, ndim, ndim_from])

Create a diagonal array given the diagonal elements.

make_equal_length(*shapes)

Make tuples equal length.

make_equal_ndim(*arrays)

Add trailing unit axes so that arrays have equal ndim

mean(X[, axis, keepdims])

Compute the mean, ignoring NaNs.

moveaxis(A, axis_from, axis_to)

Move the axis axis_from to position axis_to.

multidigamma(a, d)

Returns the derivative of the log of multivariate gamma.

multiply(*arrays)

multiply_shapes(*shapes)

Compute element-wise product of lists/tuples.

nans([size])

nested_iterator(max_inds)

normalized_exp(phi)

Compute exp(phi) so that exp(phi) sums to one.

parse_command_line_arguments(mandatory_args, ...)

Parse command line arguments of style "--parameter=value".

put(x, indices, y[, axis, ufunc])

A kind of inverse mapping of np.take

put_simple(y, indices[, axis, length])

An inverse operation of np.take with accumulation and broadcasting.

remove_whitespace(s)

repeat_to_shape(A, s)

reshape_axes(X, *shapes)

rmse(y1, y2[, axis])

safe_indices(inds, shape)

Makes sure that indices are valid for given shape.

squeeze(X)

Remove leading axes that have unit length.

squeeze_to_dim(X, dim)

sum_multiply(*args[, axis, sumaxis, keepdims])

sum_multiply_to_plates(*arrays[, to_plates, ...])

Compute the product of the arguments and sum to the target shape.

sum_product(*args[, axes_to_keep, ...])

sum_to_dim(A, dim)

Sum leading axes of A such that A has dim dimensions.

sum_to_shape(X, s)

Sum axes of the array such that the resulting shape is as given.

symm(X)

Make X symmetric.

tempfile([prefix, suffix])

trues(shape)

unique(l)

Remove duplicate items from a list while preserving order.

write_to_hdf5(group, data, name)

Writes the given array into the HDF5 file.

zipper_merge(*lists)

Combines lists by alternating elements from them.

Classes

TestCase([methodName])

Simple base class for unit testing.