smile.plot
Class Histogram
- java.lang.Object
-
- smile.plot.Shape
-
- smile.plot.Plot
-
- smile.plot.BarPlot
-
- smile.plot.Histogram
-
public class Histogram extends BarPlot
A histogram is a graphical display of tabulated frequencies, shown as bars. It shows what proportion of cases fall into each of several categories: it is a form of data binning. The categories are usually specified as non-overlapping intervals of some variable. The categories (bars) must be adjacent. The intervals (or bands, or bins) are generally of the same size, and are most easily interpreted if they are.
-
-
Constructor Summary
Constructors Constructor and Description Histogram(double[] data)Constructor.Histogram(double[] data, boolean prob)Constructor.Histogram(double[] data, double[] breaks)Constructor.Histogram(double[] data, double[] breaks, boolean prob)Constructor.Histogram(double[] data, int k)Constructor.Histogram(double[] data, int k, boolean prob)Constructor.Histogram(int[] data)Constructor.Histogram(int[] data, boolean prob)Constructor.Histogram(int[] data, double[] breaks)Constructor.Histogram(int[] data, double[] breaks, boolean prob)Constructor.Histogram(int[] data, int k)Constructor.Histogram(int[] data, int k, boolean prob)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description double[][]getHistogram()Returns the bin centers and frequencies/probabilities.intgetNumBins()Returns the number of bins in the histogram.java.lang.StringgetToolTip(double[] coord)Returns a optional tool tip for the object at given coordinates.static PlotCanvasplot(double[] data)Create a plot canvas with the histogram plot.static PlotCanvasplot(double[] data, double[] breaks)Create a plot canvas with the histogram plot of given data.static PlotCanvasplot(double[] data, int k)Create a plot canvas with the histogram plot of given data.static PlotCanvasplot(int[] data)Create a plot canvas with the histogram plot.static PlotCanvasplot(int[] data, double[] breaks)Create a plot canvas with the histogram plot of given data.static PlotCanvasplot(int[] data, int k)Create a plot canvas with the histogram plot of given data.static PlotCanvasplot(java.lang.String id, double[] data)Create a plot canvas with the histogram plot.static PlotCanvasplot(java.lang.String id, double[] data, double[] breaks)Create a plot canvas with the histogram plot of given data.static PlotCanvasplot(java.lang.String id, double[] data, double[] breaks, boolean prob)Create a plot canvas with the histogram plot of given data.static PlotCanvasplot(java.lang.String id, double[] data, int k)Create a plot canvas with the histogram plot of given data.static PlotCanvasplot(java.lang.String id, int[] data)Create a plot canvas with the histogram plot.static PlotCanvasplot(java.lang.String id, int[] data, double[] breaks)Create a plot canvas with the histogram plot of given data.static PlotCanvasplot(java.lang.String id, int[] data, int k)Create a plot canvas with the histogram plot of given data.-
Methods inherited from class smile.plot.Plot
getID, getToolBar, setID
-
-
-
-
Constructor Detail
-
Histogram
public Histogram(int[] data)
Constructor. The number of bins will be determined by square-root rule and the y-axis will be in the probability scale.- Parameters:
data- a sample set.
-
Histogram
public Histogram(int[] data, boolean prob)Constructor. The number of bins will be determined by square-root rule.- Parameters:
data- a sample set.prob- if true, the y-axis will be in the probability scale. Otherwise, y-axis will be in the frequency scale.
-
Histogram
public Histogram(int[] data, int k)Constructor. The number of bins will be determined by square-root rule and the y-axis will be in the probability scale.- Parameters:
data- a sample set.k- the number of bins.
-
Histogram
public Histogram(int[] data, int k, boolean prob)Constructor.- Parameters:
data- a sample set.k- the number of bins.prob- if true, the y-axis will be in the probability scale. Otherwise, y-axis will be in the frequency scale.
-
Histogram
public Histogram(int[] data, double[] breaks)Constructor. The number of bins will be determined by square-root rule and the y-axis will be in the probability scale.- Parameters:
data- a sample set.breaks- an array of size k+1 giving the breakpoints between histogram cells. Must be in ascending order.
-
Histogram
public Histogram(int[] data, double[] breaks, boolean prob)Constructor.- Parameters:
data- a sample set.breaks- an array of size k+1 giving the breakpoints between histogram cells. Must be in ascending order.prob- if true, the y-axis will be in the probability scale. Otherwise, y-axis will be in the frequency scale.
-
Histogram
public Histogram(double[] data)
Constructor. The number of bins will be determined by square-root rule and the y-axis will be in the probability scale.- Parameters:
data- a sample set.
-
Histogram
public Histogram(double[] data, boolean prob)Constructor. The number of bins will be determined by square-root rule.- Parameters:
data- a sample set.prob- if true, the y-axis will be in the probability scale. Otherwise, y-axis will be in the frequency scale.
-
Histogram
public Histogram(double[] data, int k)Constructor. The y-axis will be in the probability scale.- Parameters:
data- a sample set.k- the number of bins.
-
Histogram
public Histogram(double[] data, int k, boolean prob)Constructor.- Parameters:
data- a sample set.k- the number of bins.prob- if true, the y-axis will be in the probability scale. Otherwise, y-axis will be in the frequency scale.
-
Histogram
public Histogram(double[] data, double[] breaks)Constructor. The y-axis will be in the probability scale.- Parameters:
data- a sample set.breaks- an array of size k+1 giving the breakpoints between histogram cells. Must be in ascending order.
-
Histogram
public Histogram(double[] data, double[] breaks, boolean prob)Constructor.- Parameters:
data- a sample set.breaks- an array of size k+1 giving the breakpoints between histogram cells. Must be in ascending order.prob- if true, the y-axis will be in the probability scale. Otherwise, y-axis will be in the frequency scale.
-
-
Method Detail
-
getHistogram
public double[][] getHistogram()
Returns the bin centers and frequencies/probabilities.- Returns:
- a n x 2 array, where n is the number of bins. a[][0] are the centers of bins and a[][1] are frequencies or probabilities.
-
getNumBins
public int getNumBins()
Returns the number of bins in the histogram.- Returns:
- the number of bins.
-
getToolTip
public java.lang.String getToolTip(double[] coord)
Description copied from class:PlotReturns a optional tool tip for the object at given coordinates.- Overrides:
getToolTipin classBarPlot- Parameters:
coord- the logical coordinates of current mouse position.- Returns:
- a string if an object with label close to the given coordinates. Otherwise null.
-
plot
public static PlotCanvas plot(double[] data)
Create a plot canvas with the histogram plot.- Parameters:
data- a sample set.
-
plot
public static PlotCanvas plot(java.lang.String id, double[] data)
Create a plot canvas with the histogram plot.- Parameters:
id- the id of the plot.data- a sample set.
-
plot
public static PlotCanvas plot(double[] data, int k)
Create a plot canvas with the histogram plot of given data.- Parameters:
data- a sample set.k- the number of bins.
-
plot
public static PlotCanvas plot(java.lang.String id, double[] data, int k)
Create a plot canvas with the histogram plot of given data.- Parameters:
id- the id of the plot.data- a sample set.k- the number of bins.
-
plot
public static PlotCanvas plot(double[] data, double[] breaks)
Create a plot canvas with the histogram plot of given data.- Parameters:
data- a sample set.breaks- an array of size k+1 giving the breakpoints between histogram cells. Must be in ascending order.
-
plot
public static PlotCanvas plot(java.lang.String id, double[] data, double[] breaks)
Create a plot canvas with the histogram plot of given data.- Parameters:
id- the id of the plot.data- a sample set.breaks- an array of size k+1 giving the breakpoints between histogram cells. Must be in ascending order.
-
plot
public static PlotCanvas plot(java.lang.String id, double[] data, double[] breaks, boolean prob)
Create a plot canvas with the histogram plot of given data.- Parameters:
id- the id of the plot.data- a sample set.breaks- an array of size k+1 giving the breakpoints between histogram cells. Must be in ascending order.
-
plot
public static PlotCanvas plot(int[] data)
Create a plot canvas with the histogram plot.- Parameters:
data- a sample set.
-
plot
public static PlotCanvas plot(java.lang.String id, int[] data)
Create a plot canvas with the histogram plot.- Parameters:
id- the id of the plot.data- a sample set.
-
plot
public static PlotCanvas plot(int[] data, int k)
Create a plot canvas with the histogram plot of given data.- Parameters:
data- a sample set.k- the number of bins.
-
plot
public static PlotCanvas plot(java.lang.String id, int[] data, int k)
Create a plot canvas with the histogram plot of given data.- Parameters:
id- the id of the plot.data- a sample set.k- the number of bins.
-
plot
public static PlotCanvas plot(int[] data, double[] breaks)
Create a plot canvas with the histogram plot of given data.- Parameters:
data- a sample set.breaks- an array of size k+1 giving the breakpoints between histogram cells. Must be in ascending order.
-
plot
public static PlotCanvas plot(java.lang.String id, int[] data, double[] breaks)
Create a plot canvas with the histogram plot of given data.- Parameters:
id- the id of the plot.data- a sample set.breaks- an array of size k+1 giving the breakpoints between histogram cells. Must be in ascending order.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG