[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: [1/3] commons-numbers git commit: Removed "Commons Math" code examples.
From: erans () apache ! org
Date: 2017-04-30 15:38:07
Message-ID: 9b33c704a5fc46188f24df6de5cb7e66 () git ! apache ! org
[Download RAW message or body]
Repository: commons-numbers
Updated Branches:
refs/heads/master bd596bee4 -> a960a5ca7
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/a960a5ca/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java \
b/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java \
deleted file mode 100644 index bfa3c48..0000000
--- a/src/userguide/java/org/apache/commons/math4/userguide/geometry/GeometryExample.java
+++ /dev/null
@@ -1,280 +0,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.
- */
-package org.apache.commons.complex.userguide.geometry;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.geom.Point2D;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JPanel;
-import javax.swing.JSplitPane;
-
-import org.apache.commons.complex.geometry.enclosing.Encloser;
-import org.apache.commons.complex.geometry.enclosing.EnclosingBall;
-import org.apache.commons.complex.geometry.enclosing.WelzlEncloser;
-import org.apache.commons.complex.geometry.euclidean.twod.DiskGenerator;
-import org.apache.commons.complex.geometry.euclidean.twod.Euclidean2D;
-import org.apache.commons.complex.geometry.euclidean.twod.Segment;
-import org.apache.commons.complex.geometry.euclidean.twod.Vector2D;
-import org.apache.commons.complex.geometry.euclidean.twod.hull.ConvexHull2D;
-import org.apache.commons.complex.geometry.euclidean.twod.hull.ConvexHullGenerator2D;
-import org.apache.commons.complex.geometry.euclidean.twod.hull.MonotoneChain;
-import org.apache.commons.complex.random.MersenneTwister;
-import org.apache.commons.complex.random.RandomGenerator;
-import org.apache.commons.complex.util.FastMath;
-import org.apache.commons.complex.userguide.ExampleUtils;
-import org.apache.commons.complex.userguide.ExampleUtils.ExampleFrame;
-import org.piccolo2d.PCamera;
-import org.piccolo2d.PCanvas;
-import org.piccolo2d.PNode;
-import org.piccolo2d.event.PBasicInputEventHandler;
-import org.piccolo2d.event.PInputEvent;
-import org.piccolo2d.event.PMouseWheelZoomEventHandler;
-import org.piccolo2d.nodes.PPath;
-import org.piccolo2d.nodes.PText;
-
-/**
- * Simple example illustrating some parts of the geometry package.
- *
- * TODO:
- * - select tolerance level
- * - allow editing of the point set
- */
-public class GeometryExample {
-
- public static List<Vector2D> createRandomPoints(int size) {
- RandomGenerator random = new MersenneTwister();
-
- // create the cloud container
- List<Vector2D> points = new ArrayList<Vector2D>(size);
- // fill the cloud with a random distribution of points
- for (int i = 0; i < size; i++) {
- points.add(new Vector2D(FastMath.round(random.nextDouble() * 400 + 100),
- FastMath.round(random.nextDouble() * 400 + 100)));
- }
-
- return points;
- }
-
- public static List<Vector2D> createCircle(int samples) {
- List<Vector2D> points = new ArrayList<Vector2D>();
- final Vector2D center = new Vector2D(300, 300);
- double range = 2.0 * FastMath.PI;
- double step = range / (samples + 1);
- for (double angle = 0; angle < range; angle += step) {
- Vector2D circle = new Vector2D(FastMath.cos(angle), \
FastMath.sin(angle));
- points.add(circle.scalarMultiply(200).add(center));
- }
-
- return points;
- }
-
- public static List<Vector2D> createCross() {
- List<Vector2D> points = new ArrayList<Vector2D>();
-
- for (int i = 100; i < 500; i += 10) {
- points.add(new Vector2D(300, i));
- points.add(new Vector2D(i, 300));
- }
-
- return points;
- }
-
- public static PCanvas createCanvas() {
- final PCanvas canvas = new PCanvas();
- final PCamera camera = canvas.getCamera();
-
- final PText tooltipNode = new PText();
- tooltipNode.setPickable(false);
- camera.addChild(tooltipNode);
-
- camera.addInputEventListener(new PBasicInputEventHandler() {
- public void mouseMoved(final PInputEvent event) {
- updateToolTip(event);
- }
-
- public void mouseDragged(final PInputEvent event) {
- updateToolTip(event);
- }
-
- public void updateToolTip(final PInputEvent event) {
- final PNode n = event.getPickedNode();
- final Object object = (Object) n.getAttribute("tooltip");
- if (object != null) {
- final String tooltipString = object.toString();
- final Point2D p = event.getCanvasPosition();
-
- event.getPath().canvasToLocal(p, camera);
-
- tooltipNode.setText(tooltipString);
- tooltipNode.setOffset(p.getX() + 8, p.getY() - 8);
- } else {
- tooltipNode.setText(null);
- }
- }
- });
-
- // uninstall default zoom event handler
- canvas.removeInputEventListener(canvas.getZoomEventHandler());
-
- // install mouse wheel zoom event handler
- final PMouseWheelZoomEventHandler mouseWheelZoomEventHandler = new \
PMouseWheelZoomEventHandler();
- canvas.addInputEventListener(mouseWheelZoomEventHandler);
-
- return canvas;
- }
-
- @SuppressWarnings("serial")
- public static class Display extends ExampleFrame {
-
- private List<Vector2D> points;
- private PCanvas canvas;
- private JComponent container;
- private JComponent controlPanel;
-
- public Display() {
- setTitle("Commons Math: Geometry Examples");
- setSize(800, 700);
-
- container = new JPanel(new BorderLayout());
- canvas = createCanvas();
- container.add(canvas);
- container.setBorder(BorderFactory.createLineBorder(Color.black, 1));
-
- controlPanel = new JPanel();
- JButton random = new JButton("Randomize");
- controlPanel.add(random);
-
- random.addActionListener(new ActionListener() {
-
-// @Override
- public void actionPerformed(ActionEvent e) {
- canvas.getLayer().removeAllChildren();
-
- points = createRandomPoints(1000);
- paintConvexHull();
- }
- });
-
- JButton circle = new JButton("Circle");
- controlPanel.add(circle);
-
- circle.addActionListener(new ActionListener() {
-
-// @Override
- public void actionPerformed(ActionEvent e) {
- canvas.getLayer().removeAllChildren();
-
- points = createCircle(100);
- paintConvexHull();
- }
- });
-
- JButton cross = new JButton("Cross");
- controlPanel.add(cross);
-
- cross.addActionListener(new ActionListener() {
-
-// @Override
- public void actionPerformed(ActionEvent e) {
- canvas.getLayer().removeAllChildren();
-
- points = createCross();
- paintConvexHull();
- }
- });
-
- JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, \
container, controlPanel);
- splitpane.setDividerLocation(600);
-
- add(splitpane);
-
- points = createRandomPoints(1000);
- paintConvexHull();
- }
-
- @Override
- public Component getMainPanel() {
- return container;
- }
-
- public void paintConvexHull() {
- PNode pointSet = new PNode();
- for (Vector2D point : points) {
- final PNode node = PPath.createEllipse(point.getX() - 1, \
point.getY() - 1, 2, 2);
- node.addAttribute("tooltip", point);
- node.setPaint(Color.gray);
- pointSet.addChild(node);
- }
-
- canvas.getLayer().addChild(pointSet);
-
- ConvexHullGenerator2D generator = new MonotoneChain(true, 1e-6);
- ConvexHull2D hull = generator.generate(points); \
//AklToussaintHeuristic.reducePoints(points));
-
- PNode hullNode = new PNode();
- for (Vector2D vertex : hull.getVertices()) {
- final PPath node = PPath.createEllipse(vertex.getX() - 1, \
vertex.getY() - 1, 2, 2);
- node.addAttribute("tooltip", vertex);
- node.setPaint(Color.red);
- node.setStrokePaint(Color.red);
- hullNode.addChild(node);
- }
-
- for (Segment line : hull.getLineSegments()) {
- final PPath node = PPath.createLine(line.getStart().getX(), \
line.getStart().getY(),
- line.getEnd().getX(), \
line.getEnd().getY());
- node.setPickable(false);
- node.setPaint(Color.red);
- node.setStrokePaint(Color.red);
- hullNode.addChild(node);
- }
-
- canvas.getLayer().addChild(hullNode);
-
- Encloser<Euclidean2D, Vector2D> encloser =
- new WelzlEncloser<Euclidean2D, Vector2D>(1e-10, new \
DiskGenerator());
- EnclosingBall<Euclidean2D, Vector2D> ball = encloser.enclose(points);
-
- final double radius = ball.getRadius();
- PPath ballCenter =
- PPath.createEllipse(ball.getCenter().getX() - 1, \
ball.getCenter().getY() - 1, 2, 2);
- ballCenter.setStrokePaint(Color.blue);
- ballCenter.setPaint(Color.blue);
- canvas.getLayer().addChild(0, ballCenter);
-
- PPath ballNode =
- PPath.createEllipse(ball.getCenter().getX() - radius, \
ball.getCenter().getY() - radius,
- radius * 2, radius * 2);
- ballNode.setTransparency(1.0f);
- ballNode.setStrokePaint(Color.blue);
- canvas.getLayer().addChild(0, ballNode);
- }
- }
-
- public static void main(final String[] argv) {
- ExampleUtils.showExampleFrame(new Display());
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/a960a5ca/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java \
b/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java \
deleted file mode 100644 index d4ce758..0000000
--- a/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRings.java
+++ /dev/null
@@ -1,109 +0,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.
- */
-
-package org.apache.commons.complex.userguide.sofm;
-
-import org.apache.commons.complex.geometry.euclidean.threed.Vector3D;
-import org.apache.commons.complex.geometry.euclidean.threed.Rotation;
-import org.apache.commons.complex.random.UnitSphereRandomVectorGenerator;
-import org.apache.commons.complex.distribution.RealDistribution;
-import org.apache.commons.complex.distribution.UniformRealDistribution;
-
-/**
- * Class that creates two intertwined rings.
- * Each ring is composed of a cloud of points.
- */
-public class ChineseRings {
- /** Points in the two rings. */
- private final Vector3D[] points;
-
- /**
- * @param orientationRing1 Vector othogonal to the plane containing the
- * first ring.
- * @param radiusRing1 Radius of the first ring.
- * @param halfWidthRing1 Half-width of the first ring.
- * @param radiusRing2 Radius of the second ring.
- * @param halfWidthRing2 Half-width of the second ring.
- * @param numPointsRing1 Number of points in the first ring.
- * @param numPointsRing2 Number of points in the second ring.
- */
- public ChineseRings(Vector3D orientationRing1,
- double radiusRing1,
- double halfWidthRing1,
- double radiusRing2,
- double halfWidthRing2,
- int numPointsRing1,
- int numPointsRing2) {
- // First ring (centered at the origin).
- final Vector3D[] firstRing = new Vector3D[numPointsRing1];
- // Second ring (centered around the first ring).
- final Vector3D[] secondRing = new Vector3D[numPointsRing2];
-
- // Create two rings lying in xy-plane.
- final UnitSphereRandomVectorGenerator unit
- = new UnitSphereRandomVectorGenerator(2);
-
- final RealDistribution radius1
- = new UniformRealDistribution(radiusRing1 - halfWidthRing1,
- radiusRing1 + halfWidthRing1);
- final RealDistribution widthRing1
- = new UniformRealDistribution(-halfWidthRing1, halfWidthRing1);
-
- for (int i = 0; i < numPointsRing1; i++) {
- final double[] v = unit.nextVector();
- final double r = radius1.sample();
- // First ring is in the xy-plane, centered at (0, 0, 0).
- firstRing[i] = new Vector3D(v[0] * r,
- v[1] * r,
- widthRing1.sample());
- }
-
- final RealDistribution radius2
- = new UniformRealDistribution(radiusRing2 - halfWidthRing2,
- radiusRing2 + halfWidthRing2);
- final RealDistribution widthRing2
- = new UniformRealDistribution(-halfWidthRing2, halfWidthRing2);
-
- for (int i = 0; i < numPointsRing2; i++) {
- final double[] v = unit.nextVector();
- final double r = radius2.sample();
- // Second ring is in the xz-plane, centered at (radiusRing1, 0, 0).
- secondRing[i] = new Vector3D(radiusRing1 + v[0] * r,
- widthRing2.sample(),
- v[1] * r);
- }
-
- // Move first and second rings into position.
- final Rotation rot = new Rotation(Vector3D.PLUS_K,
- orientationRing1.normalize());
- int count = 0;
- points = new Vector3D[numPointsRing1 + numPointsRing2];
- for (int i = 0; i < numPointsRing1; i++) {
- points[count++] = rot.applyTo(firstRing[i]);
- }
- for (int i = 0; i < numPointsRing2; i++) {
- points[count++] = rot.applyTo(secondRing[i]);
- }
- }
-
- /**
- * Gets all the points.
- */
- public Vector3D[] getPoints() {
- return points.clone();
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/a960a5ca/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java
----------------------------------------------------------------------
diff --git a/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java \
b/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java
deleted file mode 100644
index d769fc7..0000000
--- a/src/userguide/java/org/apache/commons/math4/userguide/sofm/ChineseRingsClassifier.java
+++ /dev/null
@@ -1,335 +0,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.
- */
-
-package org.apache.commons.complex.userguide.sofm;
-
-import java.util.Iterator;
-import java.io.PrintWriter;
-import java.io.IOException;
-import org.apache.commons.complex.ml.neuralnet.SquareNeighbourhood;
-import org.apache.commons.complex.ml.neuralnet.FeatureInitializer;
-import org.apache.commons.complex.ml.neuralnet.FeatureInitializerFactory;
-import org.apache.commons.complex.ml.neuralnet.MapUtils;
-import org.apache.commons.complex.ml.neuralnet.twod.NeuronSquareMesh2D;
-import org.apache.commons.complex.ml.neuralnet.sofm.LearningFactorFunction;
-import org.apache.commons.complex.ml.neuralnet.sofm.LearningFactorFunctionFactory;
-import org.apache.commons.complex.ml.neuralnet.sofm.NeighbourhoodSizeFunction;
-import org.apache.commons.complex.ml.neuralnet.sofm.NeighbourhoodSizeFunctionFactory;
-import org.apache.commons.complex.ml.neuralnet.sofm.KohonenUpdateAction;
-import org.apache.commons.complex.ml.neuralnet.sofm.KohonenTrainingTask;
-import org.apache.commons.complex.ml.distance.DistanceMeasure;
-import org.apache.commons.complex.ml.distance.EuclideanDistance;
-import org.apache.commons.complex.random.RandomGenerator;
-import org.apache.commons.complex.random.Well19937c;
-import org.apache.commons.complex.stat.descriptive.SummaryStatistics;
-import org.apache.commons.complex.geometry.euclidean.threed.Vector3D;
-import org.apache.commons.complex.util.FastMath;
-import org.apache.commons.complex.exception.MathUnsupportedOperationException;
-
-/**
- * SOFM for categorizing points that belong to each of two intertwined rings.
- *
- * The output currently consists in 3 text files:
- * <ul>
- * <li>"before.chinese.U.seq.dat": U-matrix of the SOFM before training</li>
- * <li>"after.chinese.U.seq.dat": U-matrix of the SOFM after training</li>
- * <li>"after.chinese.hit.seq.dat": Hit histogram after training</li>
- * <ul>
- */
-public class ChineseRingsClassifier {
- /** SOFM. */
- private final NeuronSquareMesh2D sofm;
- /** Rings. */
- private final ChineseRings rings;
- /** Distance function. */
- private final DistanceMeasure distance = new EuclideanDistance();
-
- public static void main(String[] args) {
- final ChineseRings rings = new ChineseRings(new Vector3D(1, 2, 3),
- 25, 2,
- 20, 1,
- 2000, 1500);
- final ChineseRingsClassifier classifier = new ChineseRingsClassifier(rings, \
15, 15);
- printU("before.chinese.U.seq.dat", classifier);
- classifier.createSequentialTask(100000).run();
- printU("after.chinese.U.seq.dat", classifier);
- printHit("after.chinese.hit.seq.dat", classifier);
- }
-
- /**
- * @param rings Training data.
- * @param dim1 Number of rows of the SOFM.
- * @param dim2 Number of columns of the SOFM.
- */
- public ChineseRingsClassifier(ChineseRings rings,
- int dim1,
- int dim2) {
- this.rings = rings;
- sofm = new NeuronSquareMesh2D(dim1, false,
- dim2, false,
- SquareNeighbourhood.MOORE,
- makeInitializers());
- }
-
- /**
- * Creates training tasks.
- *
- * @param numTasks Number of tasks to create.
- * @param numSamplesPerTask Number of training samples per task.
- * @return the created tasks.
- */
- public Runnable[] createParallelTasks(int numTasks,
- long numSamplesPerTask) {
- final Runnable[] tasks = new Runnable[numTasks];
- final LearningFactorFunction learning
- = LearningFactorFunctionFactory.exponentialDecay(1e-1,
- 5e-2,
- numSamplesPerTask / 2);
- final double numNeurons = FastMath.sqrt(sofm.getNumberOfRows() * \
sofm.getNumberOfColumns());
- final NeighbourhoodSizeFunction neighbourhood
- = NeighbourhoodSizeFunctionFactory.exponentialDecay(0.5 * numNeurons,
- 0.2 * numNeurons,
- numSamplesPerTask / \
2);
-
- for (int i = 0; i < numTasks; i++) {
- final KohonenUpdateAction action = new KohonenUpdateAction(distance,
- learning,
- \
neighbourhood);
- tasks[i] = new KohonenTrainingTask(sofm.getNetwork(),
- \
createRandomIterator(numSamplesPerTask),
- action);
- }
-
- return tasks;
- }
-
- /**
- * Creates a training task.
- *
- * @param numSamples Number of training samples.
- * @return the created task.
- */
- public Runnable createSequentialTask(long numSamples) {
- return createParallelTasks(1, numSamples)[0];
- }
-
- /**
- * Computes the U-matrix.
- *
- * @return the U-matrix of the network.
- */
- public double[][] computeU() {
- return MapUtils.computeU(sofm, distance);
- }
-
- /**
- * Computes the hit histogram.
- *
- * @return the histogram.
- */
- public int[][] computeHitHistogram() {
- return MapUtils.computeHitHistogram(createIterable(),
- sofm,
- distance);
- }
-
- /**
- * Computes the quantization error.
- *
- * @return the quantization error.
- */
- public double computeQuantizationError() {
- return MapUtils.computeQuantizationError(createIterable(),
- sofm.getNetwork(),
- distance);
- }
-
- /**
- * Computes the topographic error.
- *
- * @return the topographic error.
- */
- public double computeTopographicError() {
- return MapUtils.computeTopographicError(createIterable(),
- sofm.getNetwork(),
- distance);
- }
-
- /**
- * Creates the features' initializers.
- * They are sampled from a uniform distribution around the barycentre of
- * the rings.
- *
- * @return an array containing the initializers for the x, y and
- * z coordinates of the features array of the neurons.
- */
- private FeatureInitializer[] makeInitializers() {
- final SummaryStatistics[] centre = new SummaryStatistics[] {
- new SummaryStatistics(),
- new SummaryStatistics(),
- new SummaryStatistics()
- };
- for (Vector3D p : rings.getPoints()) {
- centre[0].addValue(p.getX());
- centre[1].addValue(p.getY());
- centre[2].addValue(p.getZ());
- }
-
- final double[] mean = new double[] {
- centre[0].getMean(),
- centre[1].getMean(),
- centre[2].getMean()
- };
- final double s = 0.1;
- final double[] dev = new double[] {
- s * centre[0].getStandardDeviation(),
- s * centre[1].getStandardDeviation(),
- s * centre[2].getStandardDeviation()
- };
-
- return new FeatureInitializer[] {
- FeatureInitializerFactory.uniform(mean[0] - dev[0], mean[0] + dev[0]),
- FeatureInitializerFactory.uniform(mean[1] - dev[1], mean[1] + dev[1]),
- FeatureInitializerFactory.uniform(mean[2] - dev[2], mean[2] + dev[2])
- };
- }
-
- /**
- * Creates an iterable that will present the points coordinates.
- *
- * @return the iterable.
- */
- private Iterable<double[]> createIterable() {
- return new Iterable<double[]>() {
- public Iterator<double[]> iterator() {
- return new Iterator<double[]>() {
- /** Data. */
- final Vector3D[] points = rings.getPoints();
- /** Number of samples. */
- private int n = 0;
-
- /** {@inheritDoc} */
- public boolean hasNext() {
- return n < points.length;
- }
-
- /** {@inheritDoc} */
- public double[] next() {
- return points[n++].toArray();
- }
-
- /** {@inheritDoc} */
- public void remove() {
- throw new MathUnsupportedOperationException();
- }
- };
- }
- };
- }
-
- /**
- * Creates an iterator that will present a series of points coordinates in
- * a random order.
- *
- * @param numSamples Number of samples.
- * @return the iterator.
- */
- private Iterator<double[]> createRandomIterator(final long numSamples) {
- return new Iterator<double[]>() {
- /** Data. */
- final Vector3D[] points = rings.getPoints();
- /** RNG. */
- final RandomGenerator rng = new Well19937c();
- /** Number of samples. */
- private long n = 0;
-
- /** {@inheritDoc} */
- public boolean hasNext() {
- return n < numSamples;
- }
-
- /** {@inheritDoc} */
- public double[] next() {
- ++n;
- return points[rng.nextInt(points.length)].toArray();
- }
-
- /** {@inheritDoc} */
- public void remove() {
- throw new MathUnsupportedOperationException();
- }
- };
- }
-
- /**
- * Prints the U-matrix of the map to the given filename.
- *
- * @param filename File.
- * @param sofm Classifier.
- */
- private static void printU(String filename,
- ChineseRingsClassifier sofm) {
- PrintWriter out = null;
- try {
- out = new PrintWriter(filename);
-
- final double[][] uMatrix = sofm.computeU();
- for (int i = 0; i < uMatrix.length; i++) {
- for (int j = 0; j < uMatrix[0].length; j++) {
- out.print(uMatrix[i][j] + " ");
- }
- out.println();
- }
- out.println("# Quantization error: " + sofm.computeQuantizationError());
- out.println("# Topographic error: " + sofm.computeTopographicError());
- } catch (IOException e) {
- // Do nothing.
- } finally {
- if (out != null) {
- out.close();
- }
- }
- }
-
- /**
- * Prints the hit histogram of the map to the given filename.
- *
- * @param filename File.
- * @param sofm Classifier.
- */
- private static void printHit(String filename,
- ChineseRingsClassifier sofm) {
- PrintWriter out = null;
- try {
- out = new PrintWriter(filename);
-
- final int[][] histo = sofm.computeHitHistogram();
- for (int i = 0; i < histo.length; i++) {
- for (int j = 0; j < histo[0].length; j++) {
- out.print(histo[i][j] + " ");
- }
- out.println();
- }
- } catch (IOException e) {
- // Do nothing.
- } finally {
- if (out != null) {
- out.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/a960a5ca/src/userguide/pom.xml
----------------------------------------------------------------------
diff --git a/src/userguide/pom.xml b/src/userguide/pom.xml
deleted file mode 100644
index 2f8ac91..0000000
--- a/src/userguide/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<?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.
--->
-<!--
- Stripped down maven pom used for generating example code for the commons math \
userguide.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" \
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 \
http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-math4-examples</artifactId>
- <version>4.0-SNAPSHOT</version>
- <name>Commons Math User Guide</name>
- <inceptionYear>2003</inceptionYear>
- <description>Examples</description>
- <url>http://commons.apache.org/math/</url>
- <issueManagement>
- <system>jira</system>
- <url>http://issues.apache.org/jira/browse/MATH</url>
- </issueManagement>
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/commons/proper/math/trunk</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/commons/proper/math/trunk</developerConnection>
- <url>http://svn.apache.org/viewvc/commons/proper/math/trunk</url>
- </scm>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <maven.compiler.source>1.7</maven.compiler.source>
- <maven.compiler.target>1.7</maven.compiler.target>
- </properties>
-
- <build>
- <sourceDirectory>java</sourceDirectory>
- </build>
- <reporting>
- </reporting>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-math4</artifactId>
- <classifier>tools</classifier>
- <version>4.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-math4</artifactId>
- <version>4.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>com.xeiam.xchart</groupId>
- <artifactId>xchart</artifactId>
- <version>2.3.0</version>
- </dependency>
- <dependency>
- <groupId>org.piccolo2d</groupId>
- <artifactId>piccolo2d-core</artifactId>
- <version>3.0</version>
- </dependency>
- <dependency>
- <groupId>org.piccolo2d</groupId>
- <artifactId>piccolo2d-extras</artifactId>
- <version>3.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.1</version>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/a960a5ca/src/userguide/resources/ColorfulBird.jpg
----------------------------------------------------------------------
diff --git a/src/userguide/resources/ColorfulBird.jpg \
b/src/userguide/resources/ColorfulBird.jpg deleted file mode 100644
index 5753596..0000000
Binary files a/src/userguide/resources/ColorfulBird.jpg and /dev/null differ
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/a960a5ca/src/userguide/resources/feather-small.gif
----------------------------------------------------------------------
diff --git a/src/userguide/resources/feather-small.gif \
b/src/userguide/resources/feather-small.gif deleted file mode 100644
index 9696a00..0000000
Binary files a/src/userguide/resources/feather-small.gif and /dev/null differ
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/a960a5ca/src/userguide/resources/monalisa.png
----------------------------------------------------------------------
diff --git a/src/userguide/resources/monalisa.png \
b/src/userguide/resources/monalisa.png deleted file mode 100644
index f35a3b2..0000000
Binary files a/src/userguide/resources/monalisa.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/a960a5ca/src/userguide/resources/references.txt
----------------------------------------------------------------------
diff --git a/src/userguide/resources/references.txt \
b/src/userguide/resources/references.txt deleted file mode 100644
index f05294b..0000000
--- a/src/userguide/resources/references.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-monalisa.png - http://commons.wikimedia.org/wiki/File:Mona_Lisa.jpg
-the image is public domain in the United States, and those countries with a \
copyright term of life of the author plus 100 years or less.
-
-ColorfulBird.jpg - http://www.wall321.com/Animals/Birds/colorful_birds_tropical_head_3888x2558_wallpaper_6566
\ No newline at end of file
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic