RNG-30: New module.

Sampling from statistical distributions.


Project: http://git-wip-us.apache.org/repos/asf/commons-rng/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-rng/commit/f8fd8901
Tree: http://git-wip-us.apache.org/repos/asf/commons-rng/tree/f8fd8901
Diff: http://git-wip-us.apache.org/repos/asf/commons-rng/diff/f8fd8901

Branch: refs/heads/RNG-30__sampling
Commit: f8fd8901d3e00a735c5ce5be56ee2234da33111f
Parents: ce03c8b
Author: Gilles <er...@apache.org>
Authored: Thu Nov 10 16:44:07 2016 +0100
Committer: Gilles <er...@apache.org>
Committed: Thu Nov 10 16:54:08 2016 +0100

----------------------------------------------------------------------
 commons-rng-sampling/pom.xml                    | 52 ++++++++++++++++++
 .../rng/sampling/AbstractBaseSampler.java       | 48 +++++++++++++++++
 .../rng/sampling/AbstractContinuousSampler.java | 39 ++++++++++++++
 .../rng/sampling/AbstractDiscreteSampler.java   | 39 ++++++++++++++
 .../commons/rng/sampling/ContinuousSampler.java | 29 ++++++++++
 .../commons/rng/sampling/DiscreteSampler.java   | 29 ++++++++++
 ...ousInverseCumulativeProbabilityFunction.java | 40 ++++++++++++++
 ...eteInverseCumulativeProbabilityFunction.java | 40 ++++++++++++++
 .../InverseMethodContinuousSampler.java         | 52 ++++++++++++++++++
 .../InverseMethodDiscreteSampler.java           | 52 ++++++++++++++++++
 .../rng/sampling/distribution/package-info.java | 26 +++++++++
 .../commons/rng/sampling/package-info.java      | 26 +++++++++
 commons-rng-sampling/src/site/site.xml          | 40 ++++++++++++++
 commons-rng-sampling/src/site/xdoc/index.xml    | 57 ++++++++++++++++++++
 pom.xml                                         |  1 +
 15 files changed, 570 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/pom.xml
----------------------------------------------------------------------
diff --git a/commons-rng-sampling/pom.xml b/commons-rng-sampling/pom.xml
new file mode 100644
index 0000000..451a137
--- /dev/null
+++ b/commons-rng-sampling/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";
+         xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.commons</groupId>
+    <artifactId>commons-rng</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.commons</groupId>
+  <artifactId>commons-rng-sampling</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Apache Commons RNG Sampling</name>
+
+  <inceptionYear>2016</inceptionYear>
+  <description>The Apache Commons RNG Sampling module provides samplers
+    for various distributions.</description>
+  <url>http://commons.apache.org/proper/commons-rng/sampling/</url>
+
+  <properties>
+    <!-- This value must reflect the current name of the base package. -->
+    
<commons.osgi.symbolicName>org.apache.commons.rng.sampling</commons.osgi.symbolicName>
+    <!-- OSGi -->
+    <commons.osgi.export>org.apache.commons.rng.sampling</commons.osgi.export>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-rng-client-api</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-rng-simple</artifactId>
+      <version>1.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-math3</artifactId>
+      <version>3.6.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/AbstractBaseSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/AbstractBaseSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/AbstractBaseSampler.java
new file mode 100644
index 0000000..00789da
--- /dev/null
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/AbstractBaseSampler.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.sampling;
+
+import org.apache.commons.rng.UniformRandomProvider;
+
+/**
+ * Base class for a sampler.
+ */
+public class AbstractBaseSampler {
+    /** RNG. */
+    private final UniformRandomProvider rng;
+
+    /**
+     * @param rng Generator of uniformly distributed random numbers.
+     */
+    protected AbstractBaseSampler(UniformRandomProvider rng) {
+        this.rng = rng;
+    }
+
+    /**
+     * @return a random value from a uniform distribution in the
+     * interval {@code [0, 1)}.
+     */
+    protected double nextUniform() {
+        return rng.nextDouble();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return "[" + rng.toString() + "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/AbstractContinuousSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/AbstractContinuousSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/AbstractContinuousSampler.java
new file mode 100644
index 0000000..f590f66
--- /dev/null
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/AbstractContinuousSampler.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.sampling;
+
+import org.apache.commons.rng.UniformRandomProvider;
+
+/**
+ * Base class for a sampler that generates values of type {@code double}.
+ */
+public abstract class AbstractContinuousSampler
+    extends AbstractBaseSampler
+    implements ContinuousSampler {
+    /**
+     * @param rng Generator of uniformly distributed random numbers.
+     */
+    protected AbstractContinuousSampler(UniformRandomProvider rng) {
+        super(rng);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return "[continuous sampler " + super.toString() + "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/AbstractDiscreteSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/AbstractDiscreteSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/AbstractDiscreteSampler.java
new file mode 100644
index 0000000..a767aae
--- /dev/null
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/AbstractDiscreteSampler.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.sampling;
+
+import org.apache.commons.rng.UniformRandomProvider;
+
+/**
+ * Base class for a sampler that generates values of type {@code int}.
+ */
+public abstract class AbstractDiscreteSampler
+    extends AbstractBaseSampler
+    implements DiscreteSampler {
+    /**
+     * @param rng Generator of uniformly distributed random numbers.
+     */
+    protected AbstractDiscreteSampler(UniformRandomProvider rng) {
+        super(rng);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return "[discrete sampler " + super.toString() + "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ContinuousSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ContinuousSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ContinuousSampler.java
new file mode 100644
index 0000000..502c168
--- /dev/null
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/ContinuousSampler.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.sampling;
+
+/**
+ * Sampler that generates values of type {@code double}.
+ */
+public interface ContinuousSampler {
+    /**
+     * Creates a sample.
+     *
+     * @return a sample.
+     */
+    double sample();
+}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/DiscreteSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/DiscreteSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/DiscreteSampler.java
new file mode 100644
index 0000000..b79b2fb
--- /dev/null
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/DiscreteSampler.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.sampling;
+
+/**
+ * Sampler that generates values of type {@code int}.
+ */
+public interface DiscreteSampler {
+    /**
+     * Creates a sample.
+     *
+     * @return a sample.
+     */
+    int sample();
+}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousInverseCumulativeProbabilityFunction.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousInverseCumulativeProbabilityFunction.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousInverseCumulativeProbabilityFunction.java
new file mode 100644
index 0000000..789049b
--- /dev/null
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousInverseCumulativeProbabilityFunction.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.sampling.distribution;
+
+/**
+ * Interface for a continuous distribution that can be sampled using
+ * the <a href="https://en.wikipedia.org/wiki/Inverse_transform_sampling";>
+ * inversion method</a>.
+ */
+public interface ContinuousInverseCumulativeProbabilityFunction {
+    /**
+     * Computes the quantile function of the distribution.
+     * For a random variable {@code X} distributed according to this 
distribution,
+     * the returned value is
+     * <ul>
+     *  <li>\( \inf_{x \in \mathcal{R}} P(X \le x) \ge p \) for \( 0 < p \le 1 
\)</li>
+     *  <li>\( \inf_{x \in \mathcal{R}} P(X \le x) > 0   \) for \( p = 0 
\)</li>
+     * </ul>
+     *
+     * @param p Cumulative probability.
+     * @return the smallest {@code p}-quantile of the distribution
+     * (largest 0-quantile for {@code p = 0}).
+     * @throws IllegalArgumentException if {@code p < 0} or {@code p > 1}.
+     */
+    double inverseCumulativeProbability(double p);
+}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteInverseCumulativeProbabilityFunction.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteInverseCumulativeProbabilityFunction.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteInverseCumulativeProbabilityFunction.java
new file mode 100644
index 0000000..31822cb
--- /dev/null
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/DiscreteInverseCumulativeProbabilityFunction.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.sampling.distribution;
+
+/**
+ * Interface for a discrete distribution that can be sampled using
+ * the <a href="https://en.wikipedia.org/wiki/Inverse_transform_sampling";>
+ * inversion method</a>.
+ */
+public interface DiscreteInverseCumulativeProbabilityFunction {
+    /**
+     * Computes the quantile function of the distribution.
+     * For a random variable {@code X} distributed according to this 
distribution,
+     * the returned value is
+     * <ul>
+     *  <li>\( \inf_{x \in \mathcal{Z}} P(X \le x) \ge p \) for \( 0 < p \le 1 
\)</li>
+     *  <li>\( \inf_{x \in \mathcal{Z}} P(X \le x) > 0   \) for \( p = 0 
\)</li>
+     * </ul>
+     *
+     * @param p Cumulative probability.
+     * @return the smallest {@code p}-quantile of the distribution
+     * (largest 0-quantile for {@code p = 0}).
+     * @throws IllegalArgumentException if {@code p < 0} or {@code p > 1}.
+     */
+    int inverseCumulativeProbability(double p);
+}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseMethodContinuousSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseMethodContinuousSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseMethodContinuousSampler.java
new file mode 100644
index 0000000..8f71089
--- /dev/null
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseMethodContinuousSampler.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.sampling.distribution;
+
+import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.sampling.AbstractContinuousSampler;
+
+/**
+ * Distribution sampler that uses the
+ * <a href="https://en.wikipedia.org/wiki/Inverse_transform_sampling";>
+ * inversion method</a>.
+ */
+public class InverseMethodContinuousSampler extends AbstractContinuousSampler {
+    /** Inverse cumulative probability function. */
+    private final ContinuousInverseCumulativeProbabilityFunction function;
+
+    /**
+     * @param rng Generator of uniformly distributed random numbers.
+     * @param function Inverse cumulative probability function.
+     */
+    public InverseMethodContinuousSampler(UniformRandomProvider rng,
+                                          
ContinuousInverseCumulativeProbabilityFunction function) {
+        super(rng);
+        this.function = function;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public double sample() {
+        return function.inverseCumulativeProbability(nextUniform());
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return "[inverse method " + super.toString() + "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseMethodDiscreteSampler.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseMethodDiscreteSampler.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseMethodDiscreteSampler.java
new file mode 100644
index 0000000..f80e0a3
--- /dev/null
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/InverseMethodDiscreteSampler.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.rng.sampling.distribution;
+
+import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.sampling.AbstractDiscreteSampler;
+
+/**
+ * Distribution sampler that uses the
+ * <a href="https://en.wikipedia.org/wiki/Inverse_transform_sampling";>
+ * inversion method</a>.
+ */
+public class InverseMethodDiscreteSampler extends AbstractDiscreteSampler {
+    /** Inverse cumulative probability function. */
+    private final DiscreteInverseCumulativeProbabilityFunction function;
+
+    /**
+     * @param rng Generator of uniformly distributed random numbers.
+     * @param function Inverse cumulative probability function.
+     */
+    public InverseMethodDiscreteSampler(UniformRandomProvider rng,
+                                        
DiscreteInverseCumulativeProbabilityFunction function) {
+        super(rng);
+        this.function = function;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public int sample() {
+        return function.inverseCumulativeProbability(nextUniform());
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String toString() {
+        return "[inverse method " + super.toString() + "]";
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/package-info.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/package-info.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/package-info.java
new file mode 100644
index 0000000..863fd22
--- /dev/null
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <h3>Distribution samplers</h3>
+ *
+ * <p>
+ * This package contains classes fro sampling from statistical distributions.
+ * </p>
+ */
+
+package org.apache.commons.rng.sampling.distribution;

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/package-info.java
----------------------------------------------------------------------
diff --git 
a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/package-info.java
 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/package-info.java
new file mode 100644
index 0000000..df36938
--- /dev/null
+++ 
b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * <h3>Samplers</h3>
+ *
+ * <p>
+ * This package defines the samplers API.
+ * </p>
+ */
+
+package org.apache.commons.rng.sampling;

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/site/site.xml
----------------------------------------------------------------------
diff --git a/commons-rng-sampling/src/site/site.xml 
b/commons-rng-sampling/src/site/site.xml
new file mode 100644
index 0000000..7da2c99
--- /dev/null
+++ b/commons-rng-sampling/src/site/site.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project name="RNG">
+  <bannerRight>
+    <name>Apache Commons RNG</name>
+    <src>/images/commons_rng.small.png</src>
+    <href>/index.html</href>
+  </bannerRight>
+
+  <body>
+    <menu name="RNG Sampling">
+      <item name="Overview" href="index.html"/>
+      <item name="Latest API docs (development)"
+            href="apidocs/index.html"/>
+      <item name="Javadoc (1.0 release)"
+            
href="http://commons.apache.org/rng/client-api/javadocs/api-1.0/index.html"/>
+    </menu>
+    
+    <head>
+      <script type="text/javascript" 
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";>
+      </script>
+    </head>
+
+  </body>
+</project>

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/commons-rng-sampling/src/site/xdoc/index.xml
----------------------------------------------------------------------
diff --git a/commons-rng-sampling/src/site/xdoc/index.xml 
b/commons-rng-sampling/src/site/xdoc/index.xml
new file mode 100644
index 0000000..e4c86fd
--- /dev/null
+++ b/commons-rng-sampling/src/site/xdoc/index.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  -->
+  
+<document>
+
+  <properties>
+    <title>Commons RNG Sampling</title>
+  </properties>
+
+  <body>
+
+    <section name="Apache Commons RNG: Random Numbers Generators" 
href="summary">
+      <p>
+        Commons RNG provides implementations of pseudo-random numbers 
generators that are
+        either faster or of higher quality (and sometimes both) than 
<code>java.util.Random</code>.
+      </p>
+
+      <p>
+        The "sampling" module contains classes to generate samples that follow 
the statistics
+        of a given distribution.
+      </p>
+
+      <p>
+        Example:
+
+<source>import org.apache.commons.rng.UniformRandomProvider;
+import org.apache.commons.rng.simple.RandomSource;
+
+  // TODO
+}
+</source>
+      </p>
+
+      <p>
+        Browse the <a href="apidocs/index.html">Javadoc</a> for more 
information.
+      </p>
+    </section>
+
+  </body>
+
+</document>

http://git-wip-us.apache.org/repos/asf/commons-rng/blob/f8fd8901/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a78a2a4..fd988c7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -594,6 +594,7 @@
     <module>commons-rng-client-api</module>
     <module>commons-rng-core</module>
     <module>commons-rng-simple</module>
+    <module>commons-rng-sampling</module>
     <module>commons-rng-jmh</module>
     <module>commons-rng-examples</module>
   </modules>

Reply via email to