SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
PPPlot.java
1/*
2 * Class: PPPlot
3 * Description: pp-plot
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author Richard Simard
9 * @since May 2011
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.charts;
26
27import umontreal.ssj.probdist.ContinuousDistribution;
28import java.util.Arrays;
29
42public class PPPlot extends XYLineChart {
43 private double[][] U; // u_i = cdf(x_i)
44 private double[][] Lin; // line y = x
45
46 private void initLinear() {
47 // line y = x in [0, 1] by steps of h
48 int m = 100;
49 double h = 1.0 / m;
50 Lin = new double[2][m + 1];
51 for (int i = 0; i <= m; i++)
52 Lin[0][i] = Lin[1][i] = h * i;
53 }
54
55 private void initPoints(ContinuousDistribution dist, double[] data, int numPoints) {
56 int i;
57 U = new double[2][numPoints];
58
59 for (i = 0; i < numPoints; i++)
60 U[1][i] = dist.cdf(data[i]);
61 Arrays.sort(U[1]);
62 for (i = 0; i < numPoints; i++)
63 U[0][i] = (double) (i + 1) / numPoints;
64 }
65
81 public PPPlot(String title, String XLabel, String YLabel, ContinuousDistribution dist, double[] X) {
82 this(title, XLabel, YLabel, dist, X, X.length);
83 }
84
98 public PPPlot(String title, String XLabel, String YLabel, ContinuousDistribution dist, double[] X, int numPoints) {
99 super();
100 initPoints(dist, X, numPoints);
101 initLinear();
102 dataset = new XYListSeriesCollection(U, Lin);
103 // --- dashed line for y = x
104 ((XYListSeriesCollection) dataset).setDashPattern(1, "dashed");
105 init(title, XLabel, YLabel);
106 }
107
125 public PPPlot(String title, String XLabel, String YLabel, ContinuousDistribution dist, double[][] data, int r) {
126 this(title, XLabel, YLabel, dist, data[r], data[r].length);
127 }
128}
PPPlot(String title, String XLabel, String YLabel, ContinuousDistribution dist, double[] X, int numPoints)
Similar to the constructor PPPlot(title, XLabel, YLabel, dist, X) above, except that only the first n...
Definition PPPlot.java:98
PPPlot(String title, String XLabel, String YLabel, ContinuousDistribution dist, double[][] data, int r)
Initializes a new PPPlot instance.
Definition PPPlot.java:125
PPPlot(String title, String XLabel, String YLabel, ContinuousDistribution dist, double[] X)
Initializes a new PPPlot instance using the points X.
Definition PPPlot.java:81
XYLineChart()
Initializes a new XYLineChart instance with an empty data set.
Classes implementing continuous distributions should inherit from this base class.
double cdf(double x)
Returns the distribution function .
XYListSeriesCollection()
Stores data used in a XYLineChart or in other related charts, and provides complementary tools to dra...
void setDashPattern(int series, String dashPattern)
Selects dash pattern for a data series.