Class Histogram

java.lang.Object
edu.cmu.tetrad.data.Histogram

public class Histogram extends Object
Model for a conditional histogram for mixed continuous and discrete variables.
Version:
$Id: $Id
Author:
josephramsey
  • Constructor Summary

    Constructors
    Constructor
    Description
    Histogram(DataSet dataSet, String target, boolean removeZeroPointsPerPlot)
    This histogram is for variables in a particular data set.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addConditioningVariable(String variable, double low, double high)
    Adds a continuous conditioning variables, conditioning on a range of values.
    void
    addConditioningVariable(String variable, int value)
    Adds a discrete conditioning variable, conditioning on a particular value.
    double[]
    A convenience method to return the data for a particular named continuous variable.
    Getter for the field dataSet.
    int[]
    getFrequencies.
    double
    For a continuous target, returns the maximum value of the values histogrammed, for the unconditioned data.
    double
    For a continuous target, returns the minimum value of the values histogrammed, for the unconditioned data.
    int
    For a continuous target, returns the number of values histogrammed.
    Getter for the field target.
    getTargetNode.
    void
    Removes a conditioning variable.
    void
    setNumBins(int numBins)
    For a continuous target, sets the number of bins for the histogram.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Histogram

      public Histogram(DataSet dataSet, String target, boolean removeZeroPointsPerPlot)
      This histogram is for variables in a particular data set. These may be continuous or discrete.
      Parameters:
      dataSet - a DataSet object
      target - a String object
      removeZeroPointsPerPlot - a boolean
  • Method Details

    • addConditioningVariable

      public void addConditioningVariable(String variable, double low, double high)
      Adds a continuous conditioning variables, conditioning on a range of values.
      Parameters:
      variable - The name of the variable in the data set.
      low - The low end of the conditioning range.
      high - The high end of the conditioning range.
    • addConditioningVariable

      public void addConditioningVariable(String variable, int value)
      Adds a discrete conditioning variable, conditioning on a particular value.
      Parameters:
      variable - The name of the variable in the data set.
      value - The value to condition on.
    • removeConditioningVariable

      public void removeConditioningVariable(String variable)
      Removes a conditioning variable.
      Parameters:
      variable - The name of the conditioning variable to remove.
    • setNumBins

      public void setNumBins(int numBins)
      For a continuous target, sets the number of bins for the histogram.
      Parameters:
      numBins - The number of bins.
    • getFrequencies

      public int[] getFrequencies()

      getFrequencies.

      Returns:
      the counts for the histogram, one count for each target, in an integer array.
    • getMax

      public double getMax()
      For a continuous target, returns the maximum value of the values histogrammed, for the unconditioned data.
      Returns:
      a double
    • getMin

      public double getMin()
      For a continuous target, returns the minimum value of the values histogrammed, for the unconditioned data.
      Returns:
      a double
    • getN

      public int getN()
      For a continuous target, returns the number of values histogrammed. This may be less than the sample size of the data set because of conditioning.
      Returns:
      a int
    • getContinuousData

      public double[] getContinuousData(String variable)
      A convenience method to return the data for a particular named continuous variable.
      Parameters:
      variable - The name of the variable.
      Returns:
      an array of double objects
    • getDataSet

      public DataSet getDataSet()

      Getter for the field dataSet.

      Returns:
      the data set for this histogram.
    • getTarget

      public String getTarget()

      Getter for the field target.

      Returns:
      the target node being histogrammed. Could be continuous or discrete.
    • getTargetNode

      public Node getTargetNode()

      getTargetNode.

      Returns:
      a Node object