/** * Normalizes this Markov chain. */ public void normalize() { VectorUtil.divideByNorm1Equals(this.initialProbability); this.normalizeTransitionMatrix(this.transitionProbability); }
@Override public int getInputDimensionality() { return VectorUtil.safeGetDimensionality(this.weights); }
/** * Asserts that all of the dimensionalities of the vectors in the * given set of data are the same. * * @param data * A collection of data. * @throws DimensionalityMismatchException * If the dimensionalities are not all equal. */ public static void assertDimensionalitiesAllEqual( final Iterable<? extends Vectorizable> data) { VectorUtil.assertDimensionalitiesAllEqual(data, getDimensionality(data)); }
/** * Returns a new vector whose elements are the elements of the original * vector, divided by the 2-norm of the vector (the square root of the sum * of the squared values of the elements). If the 2-norm is zero (which * means all the elements are zero), then the result is just a duplicate * of the input (zero) vector. * * @param input * The vector to divide by its 2-norm. * @return * A new vector whose elements are the elements from the given vector, * divided by its 2-norm. */ public static Vector divideByNorm2( final Vector input) { final Vector clone = input.clone(); divideByNorm2Equals(clone); return clone; }
/** * Performs linear interpolation between two vectors. * * If percent is between 0.0 and 1.0, the result is: percent (y - x) + x. * If percent is less than 0.0, the result is x. If percent is * greater than 1.0, the result is y. * * @param first * The first vector. Sometimes this is referred to as x. * @param second * The second vector. Sometimes this is referred to as y. * @param percent * A value between 0.0 and 1.0 to interpolate between the two vectors. * Sometimes this is also referred to as alpha. * @return * A new vector that is linearly interpolated between the two vectors * vectors. */ public static Vector interpolateLinear( final Vectorizable first, final Vectorizable second, final double percent) { return interpolateLinear( first.convertToVector(), second.convertToVector(), percent); }
/** * Returns a new vector whose elements are the elements of the original * vector, divided by the 2-norm of the vector (the square root of the sum * of the squared values of the elements). If the 2-norm is zero (which * means all the elements are zero), then the result is just a duplicate * of the input (zero) vector. * * @param input * The vector to divide by its 2-norm. * @return * A new vector whose elements are the elements from the given vector, * divided by its 2-norm. */ public static Vector divideByNorm2( final Vector input) { final Vector clone = input.clone(); divideByNorm2Equals(clone); return clone; }
/** * Performs linear interpolation between two vectors. * * If percent is between 0.0 and 1.0, the result is: percent (y - x) + x. * If percent is less than 0.0, the result is x. If percent is * greater than 1.0, the result is y. * * @param first * The first vector. Sometimes this is referred to as x. * @param second * The second vector. Sometimes this is referred to as y. * @param percent * A value between 0.0 and 1.0 to interpolate between the two vectors. * Sometimes this is also referred to as alpha. * @return * A new vector that is linearly interpolated between the two vectors * vectors. */ public static Vector interpolateLinear( final Vectorizable first, final Vectorizable second, final double percent) { return interpolateLinear( first.convertToVector(), second.convertToVector(), percent); }
@Override public int getInputDimensionality() { return VectorUtil.safeGetDimensionality(this.weights); }
/** * Normalizes this Markov chain. */ public void normalize() { VectorUtil.divideByNorm1Equals(this.initialProbability); this.normalizeTransitionMatrix(this.transitionProbability); }
/** * Asserts that all of the dimensionalities of the vectors in the * given set of data are the same. * * @param data * A collection of data. * @throws DimensionalityMismatchException * If the dimensionalities are not all equal. */ public static void assertDimensionalitiesAllEqual( final Iterable<? extends Vectorizable> data) { VectorUtil.assertDimensionalitiesAllEqual(data, getDimensionality(data)); }
/** * Returns a new vector whose elements are the elements of the original * vector, divided by the 2-norm of the vector (the square root of the sum * of the squared values of the elements). If the 2-norm is zero (which * means all the elements are zero), then the result is just a duplicate * of the input (zero) vector. * * @param input * The vector to divide by its 2-norm. * @return * A new vector whose elements are the elements from the given vector, * divided by its 2-norm. */ public static Vector divideByNorm2( final Vector input) { final Vector clone = input.clone(); divideByNorm2Equals(clone); return clone; }
/** * Performs linear interpolation between two vectors. * * If percent is between 0.0 and 1.0, the result is: percent (y - x) + x. * If percent is less than 0.0, the result is x. If percent is * greater than 1.0, the result is y. * * @param first * The first vector. Sometimes this is referred to as x. * @param second * The second vector. Sometimes this is referred to as y. * @param percent * A value between 0.0 and 1.0 to interpolate between the two vectors. * Sometimes this is also referred to as alpha. * @return * A new vector that is linearly interpolated between the two vectors * vectors. */ public static Vector interpolateLinear( final Vectorizable first, final Vectorizable second, final double percent) { return interpolateLinear( first.convertToVector(), second.convertToVector(), percent); }
@Override public int getInputDimensionality() { return VectorUtil.safeGetDimensionality(this.weights); }
/** * Normalizes this Markov chain. */ public void normalize() { VectorUtil.divideByNorm1Equals(this.initialProbability); this.normalizeTransitionMatrix(this.transitionProbability); }
/** * Asserts that all of the dimensionalities of the vectors in the * given set of data are the same. * * @param data * A collection of data. * @throws DimensionalityMismatchException * If the dimensionalities are not all equal. */ public static void assertDimensionalitiesAllEqual( final Iterable<? extends Vectorizable> data) { VectorUtil.assertDimensionalitiesAllEqual(data, getDimensionality(data)); }
/** * Gets the expected dimensionality of the input vectors for this distance * metric. * * @return * The expected input dimensionality, if it is known. If the weights * have not been set, it will be -1. */ public int getInputDimensionality() { return VectorUtil.safeGetDimensionality(this.getWeights()); }
/** * Returns a new vector whose elements are the elements of the original * vector, divided by the 1-norm of the vector (the sum of the absolute * values of the elements). If the 1-norm is zero (which means all the * elements are zero), then the result is just a duplicate of the input * (zero) vector. * * @param input * The vector to divide by its 1-norm. * @return * A new vector whose elements are the elements from the given vector, * divided by its 1-norm. */ public static Vector divideByNorm1( final Vector input) { final Vector clone = input.clone(); divideByNorm1Equals(clone); return clone; }
/** * Gets the expected dimensionality of the input vectors for this distance * metric. * * @return * The expected input dimensionality, if it is known. If the weights * have not been set, it will be -1. */ public int getInputDimensionality() { return VectorUtil.safeGetDimensionality(this.getWeights()); }
/** * Returns a new vector whose elements are the elements of the original * vector, divided by the 1-norm of the vector (the sum of the absolute * values of the elements). If the 1-norm is zero (which means all the * elements are zero), then the result is just a duplicate of the input * (zero) vector. * * @param input * The vector to divide by its 1-norm. * @return * A new vector whose elements are the elements from the given vector, * divided by its 1-norm. */ public static Vector divideByNorm1( final Vector input) { final Vector clone = input.clone(); divideByNorm1Equals(clone); return clone; }
public int getDimensionality() { return VectorUtil.safeGetDimensionality(this.getTermGlobalFrequencies()); }