25package umontreal.ssj.charts;
27import umontreal.ssj.probdist.DiscreteDistributionInt;
29import javax.swing.JFrame;
68 throw new IllegalArgumentException(
"a is bigger than b");
76 double[][] cdf =
new double[2][m];
77 double[][] probability =
new double[2][m];
79 for (
int i = 0; i < m; i++) {
81 cdf[1][i] = dist.cdf(i + a);
82 probability[0][i] = i + a;
83 probability[1][i] = dist.
prob(i + a);
86 double[][] cdfFinal =
new double[2][2 * (m - 1)];
87 for (
int i = 0; i < m - 1; i++) {
88 cdfFinal[0][2 * i] = cdf[0][i];
89 cdfFinal[0][2 * i + 1] = cdf[0][i + 1];
90 cdfFinal[1][2 * i] = cdf[1][i];
91 cdfFinal[1][2 * i + 1] = cdf[1][i];
94 cdfChart =
new XYLineChart(
"cdf: " + dist.toString(),
"",
"", cdfFinal);
95 probChart =
new XYLineChart(
"probability: " + dist.toString(),
"",
"", probability);
101 collec.setColor(0, Color.BLUE);
102 collec.setPlotStyle(0,
"thick");
103 collec.setMarksType(0,
"only marks");
106 collec.setColor(0, Color.ORANGE);
107 collec.setPlotStyle(0,
"ycomb");
108 collec.setMarksType(0,
"*");
109 collec.setDashPattern(0,
"solid");
112 private void testParam() {
113 if (a == 0 && b == 0) {
116 int xa = (int) Math.round(mean - 3.0 * sd);
119 int xb = (int) Math.round(mean + 3.0 * sd);
139 public JFrame
viewCdf(
int width,
int height,
int a,
int b) {
141 return cdfChart.view(width, height);
154 public JFrame
viewCdf(
int width,
int height) {
156 return cdfChart.view(width, height);
172 public JFrame
viewProb(
int width,
int height,
int a,
int b) {
174 return probChart.viewBar(width, height);
189 return probChart.viewBar(width, height);
200 throw new IllegalArgumentException(
"a is bigger than b" + a +
" " + b);
220 return cdfChart.toLatex(width, height);
232 return probChart.toLatex(width, height);
JFrame viewCdf(int width, int height)
Similar to method viewCdf above.
String toLatexProb(int width, int height)
Similar to toLatexCdf, but for the probability instead of the cdf.
DiscreteDistIntChart(DiscreteDistributionInt dist)
Constructor for a new DiscreteDistIntChart instance used to plot the probabilities of the discrete di...
JFrame viewCdf(int width, int height, int a, int b)
Displays a chart of the cumulative distribution function (cdf) over the interval on the screen using...
DiscreteDistIntChart(DiscreteDistributionInt dist, int a, int b)
Constructor for a new DiscreteDistIntChart instance used to plot the probabilities of the discrete di...
XYLineChart getCdf()
Returns the chart of the cdf.
String toLatexCdf(int width, int height)
Exports a chart of the cumulative probability to a LaTeX source code using PGF/TikZ.
void setParam(int a, int b)
Sets the parameters and for this object.
XYLineChart getProb()
Returns the chart of the probability.
JFrame viewProb(int width, int height, int a, int b)
Displays a chart of the probability mass function over the interval.
JFrame viewProb(int width, int height)
Similar to method viewProb above.
void setprobFlag(boolean flag)
Must be set true when plotting probabilities, false otherwise.
Provides tools to create and manage curve plots.
XYListSeriesCollection getSeriesCollection()
Returns the chart’s dataset.
Classes implementing discrete distributions over the integers should inherit from this class.
int getXsup()
Returns the upper limit of the support of the probability mass function.
abstract double prob(int x)
Returns , the probability of .
int getXinf()
Returns the lower limit of the support of the probability mass function.
double getStandardDeviation()
Returns the standard deviation of the distribution function.
double getMean()
Returns the mean of the distribution function.