Github user kinow commented on a diff in the pull request:
https://github.com/apache/commons-rng/pull/5#discussion_r143869091
--- Diff:
commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ZigguratGaussianSampler.java
---
@@ -0,0 +1,161 @@
+/*
+ * 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;
+
+/**
+ * Gaussian Sampling by
+ * <a href="https://en.wikipedia.org/wiki/Ziggurat_algorithm">Ziggurat
algorithm</a>
+ *
+ * <p>Based on
+ * "The Ziggurat Method for Generating Random Variables"<br>
+ * by George Marsaglia and Wai Wan Tsang</p>
+ *
+ * @see <a
href="http://www.jstatsoft.org/article/view/v005i08/ziggurat.pdf">Ziggurat
Method for Generating Random Variables</a>
+ *
+ * @since 1.1
+ */
+
+public class ZigguratGaussianSampler
+ extends SamplerBase
+ implements NormalizedGaussianSampler {
+
+ /**
+ * Generates values from Gaussian (normal) probability distribution
+ * It uses two tables, integers KN and reals WN. Some 99% of the time,
+ * the required x is produced by:
+ * generate a random 32-bit integer j and let i be the index formed
from
+ * the rightmost 8 bits of j. If j < k_i return x = j * w_i.
+ */
+
+ /* @param KN - an auxiliary table of integers, k_i =
2^32*(x_{i-1}/x_i) */
+ private static final int[] KN = new int[128];
+ /* @param WN - table of doubles, w_i = x_i/2^32 */
+ private static final double[] WN = new double[128];
+ /**
+ * This is a Javadoc. @param FN - the function values table
+ * (normalized gaussian in this implementation)
+ * f_i(x_i) = exp(-x_i^2/2)
+ */
+ private static final double[] FN = new double[128];
--- End diff --
Oh, sorry, I think that was a bad example. What I meant to say, is that
your comments had to be something like this:
```
/** An auxiliary table of integers, k_i = 2^32*(x_{i-1}/x_i) */
private static final int[] KN = new int[128];
/** Table of doubles, w_i = x_i/2^32 */
private static final double[] WN = new double[128];
/** The function values table (normalized gaussian in this
implementation) f_i(x_i) = exp(-x_i^2/2) */
private static final double[] FN = new double[128];
```
It is the double * after the / character that marks the comment as Javadoc
or not. And the param annotation is necessary only for method parameters.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]