25package umontreal.ssj.charts;
27import umontreal.ssj.probdist.ContinuousDistribution;
29import javax.swing.JFrame;
39 protected double a, b;
45 double[][] cdf =
new double[2][m + 1];
46 double[][] density =
new double[2][m + 1];
47 double h = (b - a) / m;
52 for (
int i = 0; i <= m; i++) {
55 cdf[1][i] = dist.cdf(x);
57 cdfChart =
new XYLineChart(
"cdf: " + dist.toString(),
"",
"", cdf);
58 }
catch (UnsupportedOperationException e) {
60 System.err.println(e);
65 for (
int i = 0; i <= m; i++) {
68 density[1][i] = dist.density(x);
70 densityChart =
new XYLineChart(
"density: " + dist.toString(),
"",
"", density);
71 }
catch (UnsupportedOperationException e) {
72 System.err.println(e);
77 densityChart.setprobFlag(
true);
109 public JFrame
viewCdf(
int width,
int height) {
110 return cdfChart.view(width, height);
121 return densityChart.view(width, height);
137 return cdfChart.toLatex(width, height);
148 return densityChart.toLatex(width, height);
void setParam(double a, double b, int m)
Sets the parameters , and for this object.
ContinuousDistChart(ContinuousDistribution dist, double a, double b, int m)
Constructor for a new ContinuousDistChart instance.
JFrame viewDensity(int width, int height)
Similar to viewCdf, but for the probability density instead of the cdf.
JFrame viewCdf(int width, int height)
Displays a chart of the cumulative distribution function (cdf) on the screen using Swing.
String toLatexDensity(int width, int height)
Similar to toLatexCdf, but for the probability density instead of the cdf.
String toLatexCdf(int width, int height)
Exports a chart of the cdf to a LaTeX source code using PGF/TikZ.
void setprobFlag(boolean flag)
Must be set true when plotting probabilities, false otherwise.
Provides tools to create and manage curve plots.
Classes implementing continuous distributions should inherit from this base class.