Tools

Make Strictly Monotonic

sinflow.tools.make_strictly_monotonic(x)

Transforms a monotonic numpy array into a strictly monotonic array by changing each value as little as possible.

Parameters:

xnp.ndarray

Input 1D numpy array which is monotonic (non-decreasing or non-increasing).

Returns:

np.ndarray

Strictly monotonic array.

Raises:

ValueError

If the input array is not monotonic.

TypeError

If the input is not a numpy array.

Maximum Sliced Wasserstein Distance

sinflow.tools.max_sliced_wasserstein_distance(x, direction, p=2)

Compute the max sliced Wasserstein distance between the data x and a standard normal distribution along the given direction.

Parameters:

xnp.ndarray of shape [N, D]

The data points.

directionnp.ndarray of shape [D,]

The projection vector (unit norm).

pint

The power for the Wasserstein distance calculation (default is 2).

Returns:

distancefloat

The sliced Wasserstein distance.

Gradient Maximum Sliced Wasserstein Distance

Gradient Ascent Unit Vector