Repository: mahout Updated Branches: refs/heads/master 02ff22f0b -> b5c28791a
apply diamond operator where possible, this closes apache/mahout#257 Project: http://git-wip-us.apache.org/repos/asf/mahout/repo Commit: http://git-wip-us.apache.org/repos/asf/mahout/commit/b5c28791 Tree: http://git-wip-us.apache.org/repos/asf/mahout/tree/b5c28791 Diff: http://git-wip-us.apache.org/repos/asf/mahout/diff/b5c28791 Branch: refs/heads/master Commit: b5c28791a001af4c4da4f3cd31979f58173cf0ec Parents: 02ff22f Author: Karl Richter <krichter722> Authored: Sun Oct 9 20:25:38 2016 -0400 Committer: smarthi <[email protected]> Committed: Sun Oct 9 20:25:38 2016 -0400 ---------------------------------------------------------------------- .travis.yml | 5 +- .../apache/mahout/collections/Arithmetic.java | 39 +++++---- .../org/apache/mahout/math/AbstractMatrix.java | 2 +- .../org/apache/mahout/math/AbstractVector.java | 6 +- .../mahout/math/CholeskyDecomposition.java | 2 +- .../org/apache/mahout/math/ConstantVector.java | 8 +- .../math/FileBasedSparseBinaryMatrix.java | 6 +- .../java/org/apache/mahout/math/Matrices.java | 4 +- .../java/org/apache/mahout/math/Matrix.java | 8 +- .../apache/mahout/math/MatrixVectorView.java | 8 +- .../java/org/apache/mahout/math/MurmurHash.java | 4 +- .../apache/mahout/math/OldQRDecomposition.java | 2 +- .../apache/mahout/math/PermutedVectorView.java | 6 +- .../org/apache/mahout/math/QRDecomposition.java | 4 +- .../org/apache/mahout/math/SparseMatrix.java | 2 +- .../java/org/apache/mahout/math/Vector.java | 35 +++++--- .../java/org/apache/mahout/math/VectorView.java | 2 +- .../math/decomposer/lanczos/LanczosSolver.java | 7 +- .../apache/mahout/math/function/Functions.java | 86 ++++++++++++++------ .../apache/mahout/math/jet/math/Arithmetic.java | 13 ++- .../apache/mahout/math/jet/random/Gamma.java | 6 +- .../math/jet/random/engine/MersenneTwister.java | 82 +++++++++---------- .../math/jet/random/sampling/RandomSampler.java | 7 +- .../mahout/math/jet/stat/Probability.java | 14 ++-- .../apache/mahout/math/list/AbstractList.java | 2 +- .../mahout/math/list/ObjectArrayList.java | 2 +- 26 files changed, 210 insertions(+), 152 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/.travis.yml ---------------------------------------------------------------------- diff --git a/.travis.yml b/.travis.yml index 1e99fd5..a0289e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,5 +35,6 @@ before_install: - export PATH=$M2_HOME/bin:$PATH -script: ./runtests.sh - +script: +- ./runtests.sh +- mvn javadoc:javadoc http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/collections/Arithmetic.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/collections/Arithmetic.java b/math/src/main/java/org/apache/mahout/collections/Arithmetic.java index f72a953..18e3200 100644 --- a/math/src/main/java/org/apache/mahout/collections/Arithmetic.java +++ b/math/src/main/java/org/apache/mahout/collections/Arithmetic.java @@ -249,11 +249,17 @@ public final class Arithmetic extends Constants { } /** - * Efficiently returns the binomial coefficient, often also referred to as "n over k" or "n choose k". The binomial - * coefficient is defined as <tt>(n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )</tt>. <ul> <li>k<0<tt>: <tt>0</tt>. - * <li>k==0<tt>: <tt>1</tt>. <li>k==1<tt>: <tt>n</tt>. <li>else: <tt>(n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k - * )</tt>. </ul> + * Efficiently returns the binomial coefficient, often also referred to as + * "n over k" or "n choose k". The binomial coefficient is defined as + * <tt>(n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )</tt>. + * <ul> <li><tt>k<0</tt>: <tt>0</tt>.</li> + * <li><tt>k==0</tt>: <tt>1</tt>.</li> + * <li><tt>k==1</tt>: <tt>n</tt>.</li> + * <li>else: <tt>(n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k)</tt>.</li> + * </ul> * + * @param n + * @param k * @return the binomial coefficient. */ public static double binomial(double n, long k) { @@ -279,7 +285,7 @@ public final class Arithmetic extends Constants { /** * Efficiently returns the binomial coefficient, often also referred to as "n over k" or "n choose k". The binomial - * coefficient is defined as <ul> <li>k<0<tt>: <tt>0</tt>. <li>k==0 || k==n<tt>: <tt>1</tt>. <li>k==1 || k==n-1<tt>: + * coefficient is defined as <ul> <li><tt>k<0</tt>: <tt>0</tt>. <li><tt>k==0 || k==n</tt>: <tt>1</tt>. <li><tt>k==1 || k==n-1</tt>: * <tt>n</tt>. <li>else: <tt>(n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )</tt>. </ul> * * @return the binomial coefficient. @@ -325,8 +331,9 @@ public final class Arithmetic extends Constants { } /** - * Returns the smallest <code>long >= value</code>. <dt>Examples: {@code 1.0 -> 1, 1.2 -> 2, 1.9 -> 2}. This - * method is safer than using (long) Math.ceil(value), because of possible rounding error. + * Returns the smallest <code>long >= value</code>. + * <dl><dt>Examples: {@code 1.0 -> 1, 1.2 -> 2, 1.9 -> 2}. This + * method is safer than using (long) Math.ceil(value), because of possible rounding error.</dt></dl> */ public static long ceil(double value) { return Math.round(Math.ceil(value)); @@ -337,15 +344,15 @@ public final class Arithmetic extends Constants { * <pre> * N-1 * - ' - * y = > coef[i] T (x/2) + * y = > coef[i] T (x/2) * - i * i=0 * </pre> * Coefficients are stored in reverse order, i.e. the zero order term is last in the array. Note N is the number of - * coefficients, not the order. <p> If coefficients are for the interval a to b, x must have been transformed to x -> + * coefficients, not the order. <p> If coefficients are for the interval a to b, x must have been transformed to x -< * 2(2x - b - a)/(b-a) before entering the routine. This maps x from (a, b) to (-1, 1), over which the Chebyshev * polynomials are defined. <p> If the coefficients are for the inverted interval, in which (a, b) is mapped to (1/b, - * 1/a), the transformation required is x -> 2(2ab/x - b - a)/(b-a). If b is infinity, this becomes x -> 4a/x - 1. + * 1/a), the transformation required is {@code x -> 2(2ab/x - b - a)/(b-a)}. If b is infinity, this becomes {@code x -> 4a/x - 1}. * <p> SPEED: <p> Taking advantage of the recurrence properties of the Chebyshev polynomials, the routine requires one * more addition per loop than evaluating a nested polynomial of the same degree. * @@ -396,7 +403,7 @@ public final class Arithmetic extends Constants { /** * Returns the largest <code>long <= value</code>. - * <dt>Examples: {@code 1.0 -> 1, 1.2 -> 1, 1.9 -> 1 <dt> 2.0 -> 2,} 2.2 -> 2, 2.9 -> 2 </code><dt> + * <dl><dt>Examples: {@code 1.0 -> 1, 1.2 -> 1, 1.9 -> 1 <dt> 2.0 -> 2, 2.2 -> 2, 2.9 -> 2}</dt></dl> * This method is safer than using (long) Math.floor(value), because of possible rounding error. */ public static long floor(double value) { @@ -421,8 +428,8 @@ public final class Arithmetic extends Constants { } /** - * Returns <tt>log(k!)</tt>. Tries to avoid overflows. For <tt>k<30</tt> simply looks up a table in O(1). For - * <tt>k>=30</tt> uses stirlings approximation. + * Returns <tt>log(k!)</tt>. Tries to avoid overflows. For <tt>k<30</tt> simply looks up a table in O(1). For + * <tt>k>=30</tt> uses stirlings approximation. * * @param k must hold <tt>k >= 0</tt>. */ @@ -445,7 +452,7 @@ public final class Arithmetic extends Constants { /** * Instantly returns the factorial <tt>k!</tt>. * - * @param k must hold <tt>k >= 0 && k < 21</tt>. + * @param k must hold {@code k >= 0 && k < 21} */ public static long longFactorial(int k) { if (k < 0) { @@ -460,8 +467,8 @@ public final class Arithmetic extends Constants { /** * Returns the StirlingCorrection. <p> Correction term of the Stirling approximation for <tt>log(k!)</tt> (series in - * 1/k, or table values for small k) with int parameter k. <p> <tt> log k! = (k + 1/2)log(k + 1) - (k + 1) + - * (1/2)log(2Pi) + STIRLING_CORRECTION(k + 1) <p> log k! = (k + 1/2)log(k) - k + (1/2)log(2Pi) + + * 1/k, or table values for small k) with int parameter k. </p> <tt> log k! = (k + 1/2)log(k + 1) - (k + 1) + + * (1/2)log(2Pi) + STIRLING_CORRECTION(k + 1) log k! = (k + 1/2)log(k) - k + (1/2)log(2Pi) + * STIRLING_CORRECTION(k) </tt> */ public static double stirlingCorrection(int k) { http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/AbstractMatrix.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/AbstractMatrix.java b/math/src/main/java/org/apache/mahout/math/AbstractMatrix.java index 01f18cf..dc9ccd9 100644 --- a/math/src/main/java/org/apache/mahout/math/AbstractMatrix.java +++ b/math/src/main/java/org/apache/mahout/math/AbstractMatrix.java @@ -719,7 +719,7 @@ public abstract class AbstractMatrix implements Matrix { /** * Used internally by assign() to update multiple indices and values at once. * Only really useful for sparse vectors (especially SequentialAccessSparseVector). - * <p/> + * <p> * If someone ever adds a new type of sparse vectors, this method must merge (index, value) pairs into the vector. * * @param updates a mapping of indices to values to merge in the vector. http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/AbstractVector.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/AbstractVector.java b/math/src/main/java/org/apache/mahout/math/AbstractVector.java index 983a755..27eddbc 100644 --- a/math/src/main/java/org/apache/mahout/math/AbstractVector.java +++ b/math/src/main/java/org/apache/mahout/math/AbstractVector.java @@ -56,7 +56,8 @@ public abstract class AbstractVector implements Vector, LengthCachingVector { } /** - * Iterates over all elements <p/> * NOTE: Implementations may choose to reuse the Element returned for performance + * Iterates over all elements <p> + * NOTE: Implementations may choose to reuse the Element returned for performance * reasons, so if you need a copy of it, you should call {@link #getElement(int)} for the given index * * @return An {@link Iterator} over all elements @@ -64,7 +65,8 @@ public abstract class AbstractVector implements Vector, LengthCachingVector { protected abstract Iterator<Element> iterator(); /** - * Iterates over all non-zero elements. <p/> NOTE: Implementations may choose to reuse the Element returned for + * Iterates over all non-zero elements. <p> + * NOTE: Implementations may choose to reuse the Element returned for * performance reasons, so if you need a copy of it, you should call {@link #getElement(int)} for the given index * * @return An {@link Iterator} over all non-zero elements http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/CholeskyDecomposition.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/CholeskyDecomposition.java b/math/src/main/java/org/apache/mahout/math/CholeskyDecomposition.java index 5443f69..5cea8e5 100644 --- a/math/src/main/java/org/apache/mahout/math/CholeskyDecomposition.java +++ b/math/src/main/java/org/apache/mahout/math/CholeskyDecomposition.java @@ -22,7 +22,7 @@ import org.apache.mahout.math.function.Functions; /** * Cholesky decomposition shamelessly ported from JAMA. - * <p/> + * <p> * A Cholesky decomposition of a semi-positive definite matrix A is a lower triangular matrix L such * that L L^* = A. If A is full rank, L is unique. If A is real, then it must be symmetric and R * will also be real. http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/ConstantVector.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/ConstantVector.java b/math/src/main/java/org/apache/mahout/math/ConstantVector.java index 847bf85..f10f631 100644 --- a/math/src/main/java/org/apache/mahout/math/ConstantVector.java +++ b/math/src/main/java/org/apache/mahout/math/ConstantVector.java @@ -47,7 +47,7 @@ public class ConstantVector extends AbstractVector { /** * Used internally by assign() to update multiple indices and values at once. * Only really useful for sparse vectors (especially SequentialAccessSparseVector). - * <p/> + * <p> * If someone ever adds a new type of sparse vectors, this method must merge (index, value) pairs into the vector. * * @param updates a mapping of indices to values to merge in the vector. @@ -77,7 +77,8 @@ public class ConstantVector extends AbstractVector { } /** - * Iterates over all elements <p/> * NOTE: Implementations may choose to reuse the Element returned + * Iterates over all elements <p> + * NOTE: Implementations may choose to reuse the Element returned * for performance reasons, so if you need a copy of it, you should call {@link #getElement(int)} * for the given index * @@ -100,7 +101,8 @@ public class ConstantVector extends AbstractVector { } /** - * Iterates over all non-zero elements. <p/> NOTE: Implementations may choose to reuse the Element + * Iterates over all non-zero elements.<p> + * NOTE: Implementations may choose to reuse the Element * returned for performance reasons, so if you need a copy of it, you should call {@link * #getElement(int)} for the given index * http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/FileBasedSparseBinaryMatrix.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/FileBasedSparseBinaryMatrix.java b/math/src/main/java/org/apache/mahout/math/FileBasedSparseBinaryMatrix.java index 56600cd..0b0c25e 100644 --- a/math/src/main/java/org/apache/mahout/math/FileBasedSparseBinaryMatrix.java +++ b/math/src/main/java/org/apache/mahout/math/FileBasedSparseBinaryMatrix.java @@ -41,13 +41,13 @@ import com.google.common.collect.Lists; * DoubleBuffer and we access that instead. The interesting aspect of this is that the values in * the matrix are binary and sparse so we don't need to store the actual data, just the location of * non-zero values. - * <p/> + * <p> * Currently file data is formatted as follows: - * <p/> + * <p> * <ul> <li>A magic number to indicate the file format.</li> <li>The size of the matrix (max rows * and columns possible)</li> <li>Number of non-zeros in each row.</li> <li>A list of non-zero * columns for each row. The list starts with a count and then has column numbers</li> </ul> - * <p/> + * <p> * It would be preferable to use something like protobufs to define the format so that we can use * different row formats for different kinds of data. For instance, Golay coding of column numbers * or compressed bit vectors might be good representations for some purposes. http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/Matrices.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/Matrices.java b/math/src/main/java/org/apache/mahout/math/Matrices.java index 09aac17..5d8b5c5 100644 --- a/math/src/main/java/org/apache/mahout/math/Matrices.java +++ b/math/src/main/java/org/apache/mahout/math/Matrices.java @@ -29,7 +29,7 @@ public final class Matrices { /** * Create a matrix view based on a function generator. - * <p/> + * <p> * The generator needs to be idempotent, i.e. returning same value * for each combination of (row, column) argument sent to generator's * {@link IntIntFunction#apply(int, int)} call. @@ -129,7 +129,7 @@ public final class Matrices { /** * Uniform [-1,1) matrix generator function. - * <p/> + * <p> * WARNING: to keep things performant, it is stateful and so not thread-safe. * You'd need to create a copy per thread (with same seed) if shared between threads. * http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/Matrix.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/Matrix.java b/math/src/main/java/org/apache/mahout/math/Matrix.java index 47ba5cf..57fab78 100644 --- a/math/src/main/java/org/apache/mahout/math/Matrix.java +++ b/math/src/main/java/org/apache/mahout/math/Matrix.java @@ -271,28 +271,28 @@ public interface Matrix extends Cloneable, VectorIterable { /** * Return a map of the current column label bindings of the receiver * - * @return a Map<String, Integer> + * @return a {@code Map<String, Integer>} */ Map<String, Integer> getColumnLabelBindings(); /** * Return a map of the current row label bindings of the receiver * - * @return a Map<String, Integer> + * @return a {@code Map<String, Integer>} */ Map<String, Integer> getRowLabelBindings(); /** * Sets a map of column label bindings in the receiver * - * @param bindings a Map<String, Integer> of label bindings + * @param bindings a {@code Map<String, Integer>} of label bindings */ void setColumnLabelBindings(Map<String, Integer> bindings); /** * Sets a map of row label bindings in the receiver * - * @param bindings a Map<String, Integer> of label bindings + * @param bindings a {@code Map<String, Integer>} of label bindings */ void setRowLabelBindings(Map<String, Integer> bindings); http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/MatrixVectorView.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/MatrixVectorView.java b/math/src/main/java/org/apache/mahout/math/MatrixVectorView.java index 52ae722..6ad44b5 100644 --- a/math/src/main/java/org/apache/mahout/math/MatrixVectorView.java +++ b/math/src/main/java/org/apache/mahout/math/MatrixVectorView.java @@ -84,7 +84,8 @@ public class MatrixVectorView extends AbstractVector { } /** - * Iterates over all elements <p/> * NOTE: Implementations may choose to reuse the Element returned + * Iterates over all elements <p> + * NOTE: Implementations may choose to reuse the Element returned * for performance reasons, so if you need a copy of it, you should call {@link #getElement(int)} for * the given index * @@ -118,7 +119,8 @@ public class MatrixVectorView extends AbstractVector { } /** - * Iterates over all non-zero elements. <p/> NOTE: Implementations may choose to reuse the Element + * Iterates over all non-zero elements. <p> + * NOTE: Implementations may choose to reuse the Element * returned for performance reasons, so if you need a copy of it, you should call {@link * #getElement(int)} for the given index * @@ -274,7 +276,7 @@ public class MatrixVectorView extends AbstractVector { /** * Used internally by assign() to update multiple indices and values at once. * Only really useful for sparse vectors (especially SequentialAccessSparseVector). - * <p/> + * <p> * If someone ever adds a new type of sparse vectors, this method must merge (index, value) pairs into the vector. * * @param updates a mapping of indices to values to merge in the vector. http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/MurmurHash.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/MurmurHash.java b/math/src/main/java/org/apache/mahout/math/MurmurHash.java index 32dfdd6..13f3a07 100644 --- a/math/src/main/java/org/apache/mahout/math/MurmurHash.java +++ b/math/src/main/java/org/apache/mahout/math/MurmurHash.java @@ -23,9 +23,9 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; /** - * This is a very fast, non-cryptographic hash suitable for general hash-based + * <p>This is a very fast, non-cryptographic hash suitable for general hash-based * lookup. See http://murmurhash.googlepages.com/ for more details. - * <p/> + * </p> * <p>The C version of MurmurHash 2.0 found at that site was ported * to Java by Andrzej Bialecki (ab at getopt org).</p> */ http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/OldQRDecomposition.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/OldQRDecomposition.java b/math/src/main/java/org/apache/mahout/math/OldQRDecomposition.java index e52dae0..e1552e4 100644 --- a/math/src/main/java/org/apache/mahout/math/OldQRDecomposition.java +++ b/math/src/main/java/org/apache/mahout/math/OldQRDecomposition.java @@ -58,7 +58,7 @@ public class OldQRDecomposition implements QR { * can be retrieved via instance methods of the returned decomposition object. * * @param a A rectangular matrix. - * @throws IllegalArgumentException if <tt>A.rows() < A.columns()</tt>. + * @throws IllegalArgumentException if {@code A.rows() < A.columns()} */ public OldQRDecomposition(Matrix a) { http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/PermutedVectorView.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/PermutedVectorView.java b/math/src/main/java/org/apache/mahout/math/PermutedVectorView.java index a76f78c..e46f326 100644 --- a/math/src/main/java/org/apache/mahout/math/PermutedVectorView.java +++ b/math/src/main/java/org/apache/mahout/math/PermutedVectorView.java @@ -67,7 +67,7 @@ public class PermutedVectorView extends AbstractVector { /** * Used internally by assign() to update multiple indices and values at once. * Only really useful for sparse vectors (especially SequentialAccessSparseVector). - * <p/> + * <p> * If someone ever adds a new type of sparse vectors, this method must merge (index, value) pairs into the vector. * * @param updates a mapping of indices to values to merge in the vector. @@ -102,7 +102,7 @@ public class PermutedVectorView extends AbstractVector { } /** - * Iterates over all elements <p/> * NOTE: Implementations may choose to reuse the Element + * Iterates over all elements <p> * NOTE: Implementations may choose to reuse the Element * returned for performance reasons, so if you need a copy of it, you should call {@link * #getElement(int)} for the given index * @@ -143,7 +143,7 @@ public class PermutedVectorView extends AbstractVector { } /** - * Iterates over all non-zero elements. <p/> NOTE: Implementations may choose to reuse the Element + * Iterates over all non-zero elements. <p> NOTE: Implementations may choose to reuse the Element * returned for performance reasons, so if you need a copy of it, you should call {@link * #getElement(int)} for the given index * http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/QRDecomposition.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/QRDecomposition.java b/math/src/main/java/org/apache/mahout/math/QRDecomposition.java index db7f8d6..ab5b3d2 100644 --- a/math/src/main/java/org/apache/mahout/math/QRDecomposition.java +++ b/math/src/main/java/org/apache/mahout/math/QRDecomposition.java @@ -28,7 +28,7 @@ import org.apache.mahout.math.function.Functions; import java.util.Locale; /** - For an <tt>m x n</tt> matrix <tt>A</tt> with <tt>m >= n</tt>, the QR decomposition is an <tt>m x n</tt> + For an <tt>m x n</tt> matrix <tt>A</tt> with {@code m >= n}, the QR decomposition is an <tt>m x n</tt> orthogonal matrix <tt>Q</tt> and an <tt>n x n</tt> upper triangular matrix <tt>R</tt> so that <tt>A = Q*R</tt>. <P> @@ -53,7 +53,7 @@ public class QRDecomposition implements QR { * object. * * @param a A rectangular matrix. - * @throws IllegalArgumentException if <tt>A.rows() < A.columns()</tt>. + * @throws IllegalArgumentException if {@code A.rows() < A.columns()}. */ public QRDecomposition(Matrix a) { http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/SparseMatrix.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/SparseMatrix.java b/math/src/main/java/org/apache/mahout/math/SparseMatrix.java index 414a910..a75ac55 100644 --- a/math/src/main/java/org/apache/mahout/math/SparseMatrix.java +++ b/math/src/main/java/org/apache/mahout/math/SparseMatrix.java @@ -41,7 +41,7 @@ public class SparseMatrix extends AbstractMatrix { * * @param rows no of rows * @param columns no of columns - * @param rowVectors a Map<Integer, RandomAccessSparseVector> of rows + * @param rowVectors a {@code Map<Integer, RandomAccessSparseVector>} of rows */ public SparseMatrix(int rows, int columns, Map<Integer, Vector> rowVectors) { this(rows, columns, rowVectors, false); http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/Vector.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/Vector.java b/math/src/main/java/org/apache/mahout/math/Vector.java index ae9da6e..c3b1dc9 100644 --- a/math/src/main/java/org/apache/mahout/math/Vector.java +++ b/math/src/main/java/org/apache/mahout/math/Vector.java @@ -22,9 +22,9 @@ import org.apache.mahout.math.function.DoubleDoubleFunction; import org.apache.mahout.math.function.DoubleFunction; /** - * The basic interface including numerous convenience functions <p/> NOTE: All implementing classes must have a + * The basic interface including numerous convenience functions <p> NOTE: All implementing classes must have a * constructor that takes an int for cardinality and a no-arg constructor that can be used for marshalling the Writable - * instance <p/> NOTE: Implementations may choose to reuse the Vector.Element in the Iterable methods + * instance <p> NOTE: Implementations may choose to reuse the Vector.Element in the Iterable methods */ public interface Vector extends Cloneable { @@ -137,7 +137,8 @@ public interface Vector extends Cloneable { void mergeUpdates(OrderedIntDoubleMapping updates); /** - * A holder for information about a specific item in the Vector. <p/> When using with an Iterator, the implementation + * A holder for information about a specific item in the Vector. <p> + * When using with an Iterator, the implementation * may choose to reuse this element, so you may need to make a copy if you want to keep it */ interface Element { @@ -218,9 +219,12 @@ public interface Vector extends Cloneable { Vector normalize(); /** - * Return a new Vector containing the normalized (L_power norm) values of the recipient. <p/> See - * http://en.wikipedia.org/wiki/Lp_space <p/> Technically, when 0 < power < 1, we don't have a norm, just a metric, - * but we'll overload this here. <p/> Also supports power == 0 (number of non-zero elements) and power = {@link + * Return a new Vector containing the normalized (L_power norm) values of the recipient. <p> + * See + * http://en.wikipedia.org/wiki/Lp_space <p> + * Technically, when {@code 0 < power < 1}, we don't have a norm, just a metric, + * but we'll overload this here. <p> + * Also supports {@code power == 0} (number of non-zero elements) and power = {@link * Double#POSITIVE_INFINITY} (max element). Again, see the Wikipedia page for more info * * @param power The power to use. Must be >= 0. May also be {@link Double#POSITIVE_INFINITY}. See the Wikipedia link @@ -237,7 +241,7 @@ public interface Vector extends Cloneable { Vector logNormalize(); /** - * Return a new Vector with a normalized value calculated as log_power(1 + entry)/ L_power norm. <p/> + * Return a new Vector with a normalized value calculated as log_power(1 + entry)/ L_power norm. <p> * * @param power The power to use. Must be > 1. Cannot be {@link Double#POSITIVE_INFINITY}. * @return a new Vector @@ -245,8 +249,8 @@ public interface Vector extends Cloneable { Vector logNormalize(double power); /** - * Return the k-norm of the vector. <p/> See http://en.wikipedia.org/wiki/Lp_space <p/> Technically, when 0 > power - * < 1, we don't have a norm, just a metric, but we'll overload this here. Also supports power == 0 (number of + * Return the k-norm of the vector. <p/> See http://en.wikipedia.org/wiki/Lp_space <p> + * Technically, when {@code 0 > power < 1}, we don't have a norm, just a metric, but we'll overload this here. Also supports power == 0 (number of * non-zero elements) and power = {@link Double#POSITIVE_INFINITY} (max element). Again, see the Wikipedia page for * more info. * @@ -396,15 +400,20 @@ public interface Vector extends Cloneable { * @param other a vector to aggregate in combination with * @param aggregator function we're aggregating with; fa * @param combiner function we're combining with; fc - * @return the final aggregation; if r0 = fc(this[0], other[0]), ri = fa(r_{i-1}, fc(this[i], other[i])) - * for all i > 0 + * @return the final aggregation; {@code if r0 = fc(this[0], other[0]), ri = fa(r_{i-1}, fc(this[i], other[i])) + * for all i > 0} */ double aggregate(Vector other, DoubleDoubleFunction aggregator, DoubleDoubleFunction combiner); - /** Return the sum of squares of all elements in the vector. Square root of this value is the length of the vector. */ + /** + * Return the sum of squares of all elements in the vector. Square root of + * this value is the length of the vector. + */ double getLengthSquared(); - /** Get the square of the distance between this vector and the other vector. */ + /** + * Get the square of the distance between this vector and the other vector. + */ double getDistanceSquared(Vector v); /** http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/VectorView.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/VectorView.java b/math/src/main/java/org/apache/mahout/math/VectorView.java index f69a8c7..62c5490 100644 --- a/math/src/main/java/org/apache/mahout/math/VectorView.java +++ b/math/src/main/java/org/apache/mahout/math/VectorView.java @@ -223,7 +223,7 @@ public class VectorView extends AbstractVector { /** * Used internally by assign() to update multiple indices and values at once. * Only really useful for sparse vectors (especially SequentialAccessSparseVector). - * <p/> + * <p> * If someone ever adds a new type of sparse vectors, this method must merge (index, value) pairs into the vector. * * @param updates a mapping of indices to values to merge in the vector. http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/decomposer/lanczos/LanczosSolver.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/decomposer/lanczos/LanczosSolver.java b/math/src/main/java/org/apache/mahout/math/decomposer/lanczos/LanczosSolver.java index af72a90..61a77db 100644 --- a/math/src/main/java/org/apache/mahout/math/decomposer/lanczos/LanczosSolver.java +++ b/math/src/main/java/org/apache/mahout/math/decomposer/lanczos/LanczosSolver.java @@ -32,9 +32,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * <p>Simple implementation of the <a href="http://en.wikipedia.org/wiki/Lanczos_algorithm">Lanczos algorithm</a> for + * Simple implementation of the <a href="http://en.wikipedia.org/wiki/Lanczos_algorithm">Lanczos algorithm</a> for * finding eigenvalues of a symmetric matrix, applied to non-symmetric matrices by applying Matrix.timesSquared(vector) - * as the "matrix-multiplication" method.</p> + * as the "matrix-multiplication" method.<p> * * See the SSVD code for a better option * {@link org.apache.mahout.math.ssvd.SequentialBigSvd} @@ -48,19 +48,16 @@ import org.slf4j.LoggerFactory; * <li>generate a good starting seed vector by summing all the rows of the input matrix, and</li> * <li>compute the trace(inputMatrix<sup>t</sup>*matrix) * </ul> - * </p> * <p> * This latter value, being the sum of all of the singular values, is used to rescale the entire matrix, effectively * forcing the largest singular value to be strictly less than one, and transforming floating point <em>overflow</em> * problems into floating point <em>underflow</em> (ie, very small singular values will become invisible, as they * will appear to be zero and the algorithm will terminate). - * </p> * <p>This implementation uses {@link EigenDecomposition} to do the * eigenvalue extraction from the small (desiredRank x desiredRank) tridiagonal matrix. Numerical stability is * achieved via brute-force: re-orthogonalization against all previous eigenvectors is computed after every pass. * This can be made smarter if (when!) this proves to be a major bottleneck. Of course, this step can be parallelized * as well. - * </p> * @see org.apache.mahout.math.ssvd.SequentialBigSvd */ @Deprecated http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/function/Functions.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/function/Functions.java b/math/src/main/java/org/apache/mahout/math/function/Functions.java index 64315ce..f08c328 100644 --- a/math/src/main/java/org/apache/mahout/math/function/Functions.java +++ b/math/src/main/java/org/apache/mahout/math/function/Functions.java @@ -77,7 +77,7 @@ import java.util.Date; * public final double apply(double a, double b) { return Math.sin(a) + Math.pow(Math.cos(b),2); } * } * </pre> - * <p> For aliasing see functions. Try this <table> <td class="PRE"> + * <p> For aliasing see functions. Try this <table> <tr><td class="PRE"> * <pre> * // should yield 1.4399560356056456 in all cases * double a = 0.5; @@ -92,7 +92,7 @@ import java.util.Date; * }; * log.info(g.apply(a,b)); * </pre> - * </td> </table> + * </td></tr></table> * * <p> <H3>Performance</H3> * @@ -100,18 +100,22 @@ import java.util.Date; * performance penalty in using function objects in a loop over traditional code in a loop. For complex nested function * objects (e.g. <tt>F.chain(F.abs,F.chain(F.plus,F.sin,F.chain(F.square,F.cos)))</tt>) the penalty is zero, for trivial * functions (e.g. <tt>F.plus</tt>) the penalty is often acceptable. <center> <table border cellpadding="3" - * cellspacing="0" align="center"> <tr valign="middle" bgcolor="#33CC66" nowrap align="center"> <td nowrap colspan="7"> + * cellspacing="0" align="center"> + * <tr valign="middle" bgcolor="#33CC66" align="center"> <td nowrap colspan="7"> * <font size="+2">Iteration Performance [million function evaluations per second]</font><br> <font size="-1">Pentium - * Pro 200 Mhz, SunJDK 1.2.2, NT, java -classic, </font></td> </tr> <tr valign="middle" bgcolor="#66CCFF" nowrap - * align="center"> <td nowrap bgcolor="#FF9966" rowspan="2"> </td> <td bgcolor="#FF9966" colspan="2"> <p> 30000000 + * Pro 200 Mhz, SunJDK 1.2.2, NT, java -classic, </font></td> </tr> + * <tr valign="middle" bgcolor="#66CCFF" align="center"> <td nowrap bgcolor="#FF9966" rowspan="2"> </td> <td bgcolor="#FF9966" colspan="2"> <p> 30000000 * iterations</p> </td> <td bgcolor="#FF9966" colspan="2"> 3000000 iterations (10 times less)</td> <td bgcolor="#FF9966" - * colspan="2"> </td> </tr> <tr valign="middle" bgcolor="#66CCFF" nowrap align="center"> <td bgcolor="#FF9966"> + * colspan="2"> </td> </tr> + * <tr valign="middle" bgcolor="#66CCFF" align="center"> <td nowrap bgcolor="#FF9966"> * <tt>F.plus</tt></td> <td bgcolor="#FF9966"><tt>a+b</tt></td> <td bgcolor="#FF9966"> * <tt>F.chain(F.abs,F.chain(F.plus,F.sin,F.chain(F.square,F.cos)))</tt></td> <td bgcolor="#FF9966"> * <tt>Math.abs(Math.sin(a) + Math.pow(Math.cos(b),2))</tt></td> <td bgcolor="#FF9966"> </td> <td - * bgcolor="#FF9966"> </td> </tr> <tr valign="middle" bgcolor="#66CCFF" nowrap align="center"> <td nowrap + * bgcolor="#FF9966"> </td> </tr> + * <tr valign="middle" bgcolor="#66CCFF" align="center"> <td nowrap * bgcolor="#FF9966"> </td> <td nowrap>10.8</td> <td nowrap>29.6</td> <td nowrap>0.43</td> <td nowrap>0.35</td> <td - * nowrap> </td> <td nowrap> </td> </tr> </table></center> + * nowrap> </td> <td nowrap> </td> </tr> + * </table></center> */ public final class Functions { @@ -240,7 +244,9 @@ public final class Functions { } }; - /** Function that returns <tt>a < 0 ? -1 : a > 0 ? 1 : 0</tt>. */ + /** + * Function that returns {@code a < 0 ? -1 : a > 0 ? 1 : 0}. + */ public static final DoubleFunction SIGN = new DoubleFunction() { @Override @@ -314,7 +320,9 @@ public final class Functions { } }; - /** Function that returns <tt>a < b ? -1 : a > b ? 1 : 0</tt>. */ + /** + * Function that returns <tt>a < b ? -1 : a > b ? 1 : 0</tt>. + */ public static final DoubleDoubleFunction COMPARE = new DoubleDoubleFunction() { @Override @@ -397,7 +405,9 @@ public final class Functions { } }; - /** Function that returns <tt>a > b ? 1 : 0</tt>. */ + /** + * Function that returns <tt>a > b ? 1 : 0</tt>. + */ public static final DoubleDoubleFunction GREATER = new DoubleDoubleFunction() { @Override @@ -424,7 +434,9 @@ public final class Functions { } }; - /** Function that returns <tt>a < b</tt>. */ + /** + * Function that returns {@code a < b}. + */ public static final DoubleDoubleProcedure IS_LESS = new DoubleDoubleProcedure() { @Override @@ -433,7 +445,9 @@ public final class Functions { } }; - /** Function that returns <tt>a > b</tt>. */ + /** + * Function that returns {@code a > b}. + */ public static final DoubleDoubleProcedure IS_GREATER = new DoubleDoubleProcedure() { @Override @@ -442,7 +456,9 @@ public final class Functions { } }; - /** Function that returns <tt>a < b ? 1 : 0</tt>. */ + /** + * Function that returns <tt>a < b ? 1 : 0</tt>. + */ public static final DoubleDoubleFunction LESS = new DoubleDoubleFunction() { @Override @@ -1132,8 +1148,8 @@ public final class Functions { } /** - * Constructs a function that returns <tt>(from<=a && a<=to) ? 1 : 0</tt>. <tt>a</tt> is a variable, <tt>from</tt> and - * <tt>to</tt> are fixed. + * Constructs a function that returns {@code (from<=a && a<=to) ? 1 : 0}. + * <tt>a</tt> is a variable, <tt>from</tt> and <tt>to</tt> are fixed. */ public static DoubleFunction between(final double from, final double to) { return new DoubleFunction() { @@ -1352,7 +1368,7 @@ public final class Functions { /** - * Constructs a function that returns <tt>a < b ? -1 : a > b ? 1 : 0</tt>. <tt>a</tt> is a variable, <tt>b</tt> is + * Constructs a function that returns {@code a < b ? -1 : a > b ? 1 : 0}. <tt>a</tt> is a variable, <tt>b</tt> is * fixed. */ public static DoubleFunction compare(final double b) { @@ -1404,7 +1420,10 @@ public final class Functions { }; } - /** Constructs a function that returns <tt>a > b ? 1 : 0</tt>. <tt>a</tt> is a variable, <tt>b</tt> is fixed. */ + /** + * Constructs a function that returns <tt>a > b ? 1 : 0</tt>. <tt>a</tt> + * is a variable, <tt>b</tt> is fixed. + */ public static DoubleFunction greater(final double b) { return new DoubleFunction() { @@ -1430,7 +1449,8 @@ public final class Functions { } /** - * Constructs a function that returns <tt>from<=a && a<=to</tt>. <tt>a</tt> is a variable, <tt>from</tt> and + * Constructs a function that returns {@code from<=a && a<=to}. <tt>a</tt> + * is a variable, <tt>from</tt> and * <tt>to</tt> are fixed. * * Note that DoubleProcedure is generated code and thus looks like an invalid reference unless you can see @@ -1446,7 +1466,10 @@ public final class Functions { }; } - /** Constructs a function that returns <tt>a == b</tt>. <tt>a</tt> is a variable, <tt>b</tt> is fixed. */ + /** + * Constructs a function that returns <tt>a == b</tt>. <tt>a</tt> is a + * variable, <tt>b</tt> is fixed. + */ public static DoubleProcedure isEqual(final double b) { return new DoubleProcedure() { @@ -1457,7 +1480,10 @@ public final class Functions { }; } - /** Constructs a function that returns <tt>a > b</tt>. <tt>a</tt> is a variable, <tt>b</tt> is fixed. */ + /** + * Constructs a function that returns <tt>a > b</tt>. <tt>a</tt> is a + * variable, <tt>b</tt> is fixed. + */ public static DoubleProcedure isGreater(final double b) { return new DoubleProcedure() { @@ -1468,7 +1494,10 @@ public final class Functions { }; } - /** Constructs a function that returns <tt>a < b</tt>. <tt>a</tt> is a variable, <tt>b</tt> is fixed. */ + /** + * Constructs a function that returns {@code a < b}. <tt>a</tt> is a + * variable, <tt>b</tt> is fixed. + */ public static DoubleProcedure isLess(final double b) { return new DoubleProcedure() { @@ -1479,7 +1508,10 @@ public final class Functions { }; } - /** Constructs a function that returns <tt>a < b ? 1 : 0</tt>. <tt>a</tt> is a variable, <tt>b</tt> is fixed. */ + /** + * Constructs a function that returns <tt>a < b ? 1 : 0</tt>. <tt>a</tt> is a + * variable, <tt>b</tt> is fixed. + */ public static DoubleFunction less(final double b) { return new DoubleFunction() { @@ -1491,8 +1523,8 @@ public final class Functions { } /** - * Constructs a function that returns <tt><tt>Math.log(a) / Math.log(b)</tt></tt>. <tt>a</tt> is a variable, - * <tt>b</tt> is fixed. + * Constructs a function that returns <tt>Math.log(a) / Math.log(b)</tt>. + * <tt>a</tt> is a variable, <tt>b</tt> is fixed. */ public static DoubleFunction lg(final double b) { return new DoubleFunction() { @@ -1612,10 +1644,10 @@ public final class Functions { /** * Constructs a function that returns the number rounded to the given precision; * <tt>Math.rint(a/precision)*precision</tt>. Examples: - * <pre> + * {@code * precision = 0.01 rounds 0.012 --> 0.01, 0.018 --> 0.02 * precision = 10 rounds 123 --> 120 , 127 --> 130 - * </pre> + * } */ public static DoubleFunction round(final double precision) { return new DoubleFunction() { http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/jet/math/Arithmetic.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/jet/math/Arithmetic.java b/math/src/main/java/org/apache/mahout/math/jet/math/Arithmetic.java index 2406348..83d512b 100644 --- a/math/src/main/java/org/apache/mahout/math/jet/math/Arithmetic.java +++ b/math/src/main/java/org/apache/mahout/math/jet/math/Arithmetic.java @@ -230,8 +230,12 @@ public final class Arithmetic { /** * Efficiently returns the binomial coefficient, often also referred to as "n over k" or "n choose k". The binomial - * coefficient is defined as <ul> <li>k<0<tt>: <tt>0</tt>. <li>k==0 || k==n<tt>: <tt>1</tt>. <li>k==1 || k==n-1<tt>: - * <tt>n</tt>. <li>else: <tt>(n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )</tt>. </ul> + * coefficient is defined as <ul> + * <li><tt>k<0</tt>: <tt>0</tt>.</li> + * <li><tt>k==0 || k==n</tt>: <tt>1</tt>.</li> + * <li><tt>k==1 || k==n-1</tt>: <tt>n</tt>.</li> + * <li>else: <tt>(n * n-1 * ... * n-k+1 ) / ( 1 * 2 * ... * k )</tt>.</li> + * </ul> * * @return the binomial coefficient. */ @@ -299,8 +303,9 @@ public final class Arithmetic { } /** - * Returns <tt>log(k!)</tt>. Tries to avoid overflows. For <tt>k<30</tt> simply looks up a table in O(1). For - * <tt>k>=30</tt> uses stirlings approximation. + * Returns <tt>log(k!)</tt>. Tries to avoid overflows. For {@code k<30} simply + * looks up a table in <tt>O(1)</tt>. For {@code k>=30} uses stirlings + * approximation. * * @param k must hold <tt>k >= 0</tt>. */ http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/jet/random/Gamma.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/jet/random/Gamma.java b/math/src/main/java/org/apache/mahout/math/jet/random/Gamma.java index ff40e8f..914157b 100644 --- a/math/src/main/java/org/apache/mahout/math/jet/random/Gamma.java +++ b/math/src/main/java/org/apache/mahout/math/jet/random/Gamma.java @@ -73,9 +73,9 @@ public class Gamma extends AbstractContinousDistribution { ****************************************************************** * * * FUNCTION: - gds samples a random number from the standard * - * gamma distribution with parameter a > 0. * - * Acceptance Rejection gs for a < 1 , * - * Acceptance Complement gd for a >= 1 . * + * gamma distribution with parameter a > 0. * + * Acceptance Rejection gs for a < 1 , * + * Acceptance Complement gd for a >= 1 . * * REFERENCES: - J.H. Ahrens, U. Dieter (1974): Computer methods * * for sampling from gamma, beta, Poisson and * * binomial distributions, Computing 12, 223-246. * http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/jet/random/engine/MersenneTwister.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/jet/random/engine/MersenneTwister.java b/math/src/main/java/org/apache/mahout/math/jet/random/engine/MersenneTwister.java index 603f161..8bca895 100644 --- a/math/src/main/java/org/apache/mahout/math/jet/random/engine/MersenneTwister.java +++ b/math/src/main/java/org/apache/mahout/math/jet/random/engine/MersenneTwister.java @@ -49,21 +49,21 @@ import java.util.Date; 2.5 million calls to <tt>raw()</tt> per second (Pentium Pro 200 Mhz, JDK 1.2, NT). Be aware, however, that there is a non-negligible amount of overhead required to initialize the data structures used by a MersenneTwister. Code like - <pre> + {@code double sum = 0.0; for (int i=0; i<100000; ++i) { RandomElement twister = new MersenneTwister(new Date()); sum += twister.raw(); } - </pre> + } will be wildly inefficient. Consider using - <pre> + {@code double sum = 0.0; RandomElement twister = new MersenneTwister(new Date()); - for (int i=0; i<100000; ++i) { + for (int i=0; i<100000; ++i) { sum += twister.raw(); } - </pre> + } instead. This allows the cost of constructing the MersenneTwister object to be borne only once, rather than once for each iteration in the loop. <p> @@ -71,17 +71,19 @@ import java.util.Date; "Mersenne Twister: A 623-Dimensionally Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3--30. - <dt>More info on <A HREF="http://www.math.keio.ac.jp/~matumoto/eindex.html"> Masumoto's homepage</A>. - <dt>More info on <A HREF="http://www.ncsa.uiuc.edu/Apps/CMP/RNG/www-rng.html"> Pseudo-random number - generators is on the Web</A>. - <dt>Yet <A HREF="http://nhse.npac.syr.edu/random"> some more info</A>. + <dl> + <dt>More info on <a HREF="http://www.math.keio.ac.jp/~matumoto/eindex.html"> Masumoto's homepage</a>.</dt> + <dt>More info on <a HREF="http://www.ncsa.uiuc.edu/Apps/CMP/RNG/www-rng.html"> Pseudo-random number + generators is on the Web</a>.</dt> + <dt>Yet <a HREF="http://nhse.npac.syr.edu/random"> some more info</a>.</dt> <p> The correctness of this implementation has been verified against the published output sequence <a href="http://www.math.keio.ac.jp/~nisimura/random/real2/mt19937-2.out">mt19937-2.out</a> of the C-implementation <a href="http://www.math.keio.ac.jp/~nisimura/random/real2/mt19937-2.c">mt19937-2.c</a>. (Call <tt>test(1000)</tt> to print the sequence). <dt> - Note that this implementation is <b>not synchronized</b>. + Note that this implementation is <b>not synchronized</b>.</dt> + </dl> <p> <b>Details:</b> MersenneTwister is designed with consideration of the flaws of various existing generators in mind. It is an improved version of TT800, a very successful generator. @@ -92,42 +94,40 @@ import java.util.Date; period length, for each <tt>k <= 623</tt> (except for the zero vector, which appears one time less). If one looks at only the first <tt>n <= 16</tt> bits of each number, then the property holds for even larger <tt>k</tt>, as shown in the following table (taken from the publication cited above): - <div align="center"> - <table width="75%" border="1" cellspacing="0" cellpadding="0"> + <table width="75%" border="1" cellspacing="0" cellpadding="0" summary="property table"> <tr> - <td width="2%"> <div align="center">n</div> </td> - <td width="6%"> <div align="center">1</div> </td> - <td width="5%"> <div align="center">2</div> </td> - <td width="5%"> <div align="center">3</div> </td> - <td width="5%"> <div align="center">4</div> </td> - <td width="5%"> <div align="center">5</div> </td> - <td width="5%"> <div align="center">6</div> </td> - <td width="5%"> <div align="center">7</div> </td> - <td width="5%"> <div align="center">8</div> </td> - <td width="5%"> <div align="center">9</div> </td> - <td width="5%"> <div align="center">10</div> </td> - <td width="5%"> <div align="center">11</div> </td> - <td width="10%"> <div align="center">12 .. 16</div> </td> - <td width="10%"> <div align="center">17 .. 32</div> </td> + <td width="2%" align="center"> <div>n</div> </td> + <td width="6%" align="center"> <div>1</div> </td> + <td width="5%" align="center"> <div>2</div> </td> + <td width="5%" align="center"> <div>3</div> </td> + <td width="5%" align="center"> <div>4</div> </td> + <td width="5%" align="center"> <div>5</div> </td> + <td width="5%" align="center"> <div>6</div> </td> + <td width="5%" align="center"> <div>7</div> </td> + <td width="5%" align="center"> <div>8</div> </td> + <td width="5%" align="center"> <div>9</div> </td> + <td width="5%" align="center"> <div>10</div> </td> + <td width="5%" align="center"> <div>11</div> </td> + <td width="10%" align="center"> <div>12 .. 16</div> </td> + <td width="10%" align="center"> <div>17 .. 32</div> </td> </tr> <tr> - <td width="2%"> <div align="center">k</div> </td> - <td width="6%"> <div align="center">19937</div> </td> - <td width="5%"> <div align="center">9968</div> </td> - <td width="5%"> <div align="center">6240</div> </td> - <td width="5%"> <div align="center">4984</div> </td> - <td width="5%"> <div align="center">3738</div> </td> - <td width="5%"> <div align="center">3115</div> </td> - <td width="5%"> <div align="center">2493</div> </td> - <td width="5%"> <div align="center">2492</div> </td> - <td width="5%"> <div align="center">1869</div> </td> - <td width="5%"> <div align="center">1869</div> </td> - <td width="5%"> <div align="center">1248</div> </td> - <td width="10%"> <div align="center">1246</div> </td> - <td width="10%"> <div align="center">623</div> </td> + <td width="2%" align="center"> <div>k</div> </td> + <td width="6%" align="center"> <div>19937</div> </td> + <td width="5%" align="center"> <div>9968</div> </td> + <td width="5%" align="center"> <div>6240</div> </td> + <td width="5%" align="center"> <div>4984</div> </td> + <td width="5%" align="center"> <div>3738</div> </td> + <td width="5%" align="center"> <div>3115</div> </td> + <td width="5%" align="center"> <div>2493</div> </td> + <td width="5%" align="center"> <div>2492</div> </td> + <td width="5%" align="center"> <div>1869</div> </td> + <td width="5%" align="center"> <div>1869</div> </td> + <td width="5%" align="center"> <div>1248</div> </td> + <td width="10%" align="center"> <div>1246</div> </td> + <td width="10%" align="center"> <div>623</div> </td> </tr> </table> - </div> <p> MersenneTwister generates random numbers in batches of 624 numbers at a time, so the caching and pipelining of modern systems is exploited. http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/jet/random/sampling/RandomSampler.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/jet/random/sampling/RandomSampler.java b/math/src/main/java/org/apache/mahout/math/jet/random/sampling/RandomSampler.java index 80ffb43..6804547 100644 --- a/math/src/main/java/org/apache/mahout/math/jet/random/sampling/RandomSampler.java +++ b/math/src/main/java/org/apache/mahout/math/jet/random/sampling/RandomSampler.java @@ -38,15 +38,16 @@ import java.util.Random; * already picked before, i.e. if it is not already contained in the list. * We then do the same thing again and again until we have eventually collected 10^6 distinct numbers. * Now we sort the set ascending and return it.</i> + * <dl> * <dt>It is exactly in this sense that this class returns "random" sets. * <b>Note, however, that the implementation of this class uses a technique orders of magnitudes - * better (both in time and space) than the one outlined above.</b> + * better (both in time and space) than the one outlined above.</b></dt></dl> * * <p><b>Performance:</b> Space requirements are zero. Running time is <tt>O(n)</tt> on average, * <tt>O(N)</tt> in the worst case. - * <h2 align=center>Performance (200Mhz Pentium Pro, JDK 1.2, NT)</h2> + * <h2>Performance (200Mhz Pentium Pro, JDK 1.2, NT)</h2> * <center> - * <table border="1"> + * <table border="1" summary="performance table"> * <tr> * <td align="center" width="20%">n</td> * <td align="center" width="20%">N</td> http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/jet/stat/Probability.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/jet/stat/Probability.java b/math/src/main/java/org/apache/mahout/math/jet/stat/Probability.java index 5c023f5..bcd1a86 100644 --- a/math/src/main/java/org/apache/mahout/math/jet/stat/Probability.java +++ b/math/src/main/java/org/apache/mahout/math/jet/stat/Probability.java @@ -85,13 +85,13 @@ public final class Probability { /** * Returns the sum of the terms <tt>0</tt> through <tt>k</tt> of the Negative Binomial Distribution. - * <pre> + * {@code * k * -- ( n+j-1 ) n j * > ( ) p (1-p) * -- ( j ) * j=0 - * </pre> + * } * In a sequence of Bernoulli trials, this is the probability that <tt>k</tt> or fewer failures precede the * <tt>n</tt>-th success. <p> The terms are not computed individually; instead the incomplete beta integral is * employed, according to the formula <p> <tt>y = negativeBinomial( k, n, p ) = Gamma.incompleteBeta( n, k+1, p @@ -117,7 +117,7 @@ public final class Probability { /** * Returns the area under the Normal (Gaussian) probability density function, integrated from minus infinity to * <tt>x</tt> (assumes mean is zero, variance is one). - * <pre> + * {@code * x * - * 1 | | 2 @@ -125,10 +125,10 @@ public final class Probability { * sqrt(2pi) | | * - * -inf. - * <p/> + * * = ( 1 + erf(z) ) / 2 * = erfc(z) / 2 - * </pre> + * } * where <tt>z = x/sqrt(2)</tt>. Computation is via the functions <tt>errorFunction</tt> and * <tt>errorFunctionComplement</tt>. * <p> @@ -153,7 +153,7 @@ public final class Probability { /** * Returns the area under the Normal (Gaussian) probability density function, integrated from minus infinity to * <tt>x</tt>. - * <pre> + * {@code * x * - * 1 | | 2 @@ -162,7 +162,7 @@ public final class Probability { * - * -inf. * - * </pre> + * } * where <tt>v = variance</tt>. Computation is via the functions <tt>errorFunction</tt>. * * @param mean the mean of the normal distribution. http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/list/AbstractList.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/list/AbstractList.java b/math/src/main/java/org/apache/mahout/math/list/AbstractList.java index a922652..c672f40 100644 --- a/math/src/main/java/org/apache/mahout/math/list/AbstractList.java +++ b/math/src/main/java/org/apache/mahout/math/list/AbstractList.java @@ -61,7 +61,7 @@ public abstract class AbstractList extends PersistentObject { /** * Inserts <tt>length</tt> dummy elements before the specified position into the receiver. Shifts the element * currently at that position (if any) and any subsequent elements to the right. <b>This method must set the new size - * to be <tt>size()+length</tt>. + * to be <tt>size()+length</tt></b>. * * @param index index before which to insert dummy elements (must be in [0,size]).. * @param length number of dummy elements to be inserted. http://git-wip-us.apache.org/repos/asf/mahout/blob/b5c28791/math/src/main/java/org/apache/mahout/math/list/ObjectArrayList.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/list/ObjectArrayList.java b/math/src/main/java/org/apache/mahout/math/list/ObjectArrayList.java index df3df8b..c41141f 100644 --- a/math/src/main/java/org/apache/mahout/math/list/ObjectArrayList.java +++ b/math/src/main/java/org/apache/mahout/math/list/ObjectArrayList.java @@ -369,7 +369,7 @@ public class ObjectArrayList<T> extends AbstractObjectList<T> { * Replaces the element at the specified position in the receiver with the specified element; <b>WARNING:</b> Does not * check preconditions. Provided with invalid parameters this method may access invalid indexes without throwing any * exception! <b>You should only use this method when you are absolutely sure that the index is within bounds.</b> - * Precondition (unchecked): <tt>index >= 0 && index < size()</tt>. + * Precondition (unchecked): {@code index >= 0 && index < size()}. * * @param index index of element to replace. * @param element element to be stored at the specified position.
