Package edu.cmu.tetrad.data
Class CovarianceMatrixOnTheFly
java.lang.Object
edu.cmu.tetrad.data.CovarianceMatrixOnTheFly
- All Implemented Interfaces:
- DataModel,- ICovarianceMatrix,- KnowledgeTransferable,- VariableSource,- TetradSerializable,- Serializable
Stores a covariance matrix together with variable names and sample size, intended as a representation of a data set.
 When constructed from a continuous data set, the matrix is not checked for positive definiteness; however, when a
 covariance matrix is supplied, its positive definiteness is always checked. If the sample size is less than the
 number of variables, the positive definiteness is "spot-checked"--that is, checked for various submatrices.
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionCovarianceMatrixOnTheFly(DataSet dataSet) Constructs a new covariance matrix from the given data set.CovarianceMatrixOnTheFly(DataSet dataSet, boolean verbose) Constructor for CovarianceMatrixOnTheFly.
- 
Method SummaryModifier and TypeMethodDescriptionfinal voidclearSelection.copy()copy.static voiddemean.final intgetDimension.final KnowledgeGetter for the fieldknowledge.final MatrixGetter for the fieldmatrix.final MatrixgetMatrix(int[] rows) Getter for the fieldmatrix.final StringgetName()Gets the name of the covariance matrix.final intThe size of the sample used to calculated this covariance matrix.getSelectedVariableNames.getSelection(int[] rows, int[] cols) Returns a submatrix based on the specified rows and columns.getSelection(int[] rows, int[] cols, int[] dataRows) getSelection.final intgetSize()getSize.final ICovarianceMatrixgetSubmatrix(int[] indices) getSubmatrix.final ICovarianceMatrixgetSubmatrix(int[] indices, int[] dataRows) getSubmatrix.final CovarianceMatrixOnTheFlygetSubmatrix(String[] submatrixVarNames) getSubmatrix.final ICovarianceMatrixgetSubmatrix(List<String> submatrixVarNames) getSubmatrix.final doublegetValue(int i, int j) Retrieves the value from the covariance matrix at the specified row and column indices.final doublegetValue(int i, int j, int[] rows) getValue.getVariable(String name) Retrieves a Node instance from the covariance matrix corresponding to the specified variable name.final StringgetVariableName(int index) Retrieves the name of the variable at the specified index from the covariance matrix.getVariableNames.Getter for the fieldvariables.booleanisContinuous.booleanisDiscrete.booleanisMixed()isMixed.final booleanisSelected(Node variable) Checks if the specified node is selected in the covariance matrix.booleanisVerbose.voidremoveVariables(List<String> remaining) Removes variables from the covariance matrix, retaining only the variables specified in the provided list.final voidSelects a specified variable in the covariance matrix.static ICovarianceMatrixGenerates a simple exemplar of this class to test serialization.final voidsetKnowledge(Knowledge knowledge) Sets the knowledge associated with the ICovarianceMatrix.voidSets the covariance matrix.final voidSets the name of the covariance matrix.final voidsetSampleSize(int sampleSize) Sets the sample size used in the covariance matrix.voidsetValue(int i, int j, double v) Sets the value of the covariance matrix at the specified indices.voidsetVariables(List<Node> variables) Sets the list of Node variables for the covariance matrix.voidsetVerbose(boolean verbose) Setter for the fieldverbose.final StringtoString()Prints out the matrix
- 
Constructor Details- 
CovarianceMatrixOnTheFlyConstructs a new covariance matrix from the given data set. If dataSet is a BoxDataSet with a VerticalDoubleDataBox, the data will be mean-centered by the constructor; is non-mean-centered version of the data is needed, the data should be copied before being send into the constructor.- Parameters:
- dataSet- a- DataSetobject
- Throws:
- IllegalArgumentException- if this is not a continuous data set.
 
- 
CovarianceMatrixOnTheFlyConstructor for CovarianceMatrixOnTheFly. - Parameters:
- dataSet- a- DataSetobject
- verbose- a boolean
 
 
- 
- 
Method Details- 
demeandemean. - Parameters:
- data- an array of objects
- means- a- Vectorobject
 
- 
serializableInstanceGenerates a simple exemplar of this class to test serialization.- Returns:
- a ICovarianceMatrixobject
 
- 
getVariablesGetter for the field variables.- Specified by:
- getVariablesin interface- ICovarianceMatrix
- Specified by:
- getVariablesin interface- VariableSource
- Returns:
- the list of variables (unmodifiable).
 
- 
setVariablesSets the list of Node variables for the covariance matrix.- Specified by:
- setVariablesin interface- ICovarianceMatrix
- Parameters:
- variables- a list of Node objects representing the variables to be set in the covariance matrix
 
- 
getVariableNamesgetVariableNames. - Specified by:
- getVariableNamesin interface- ICovarianceMatrix
- Specified by:
- getVariableNamesin interface- VariableSource
- Returns:
- the variable names, in order.
 
- 
getVariableNameRetrieves the name of the variable at the specified index from the covariance matrix.- Specified by:
- getVariableNamein interface- ICovarianceMatrix
- Parameters:
- index- the index of the variable whose name is to be retrieved
- Returns:
- the name of the variable at the specified index
 
- 
getDimensionpublic final int getDimension()getDimension. - Specified by:
- getDimensionin interface- ICovarianceMatrix
- Returns:
- the dimension of the covariance matrix.
 
- 
getSampleSizepublic final int getSampleSize()The size of the sample used to calculated this covariance matrix.- Specified by:
- getSampleSizein interface- ICovarianceMatrix
- Returns:
- The sample size (> 0).
 
- 
setSampleSizepublic final void setSampleSize(int sampleSize) Sets the sample size used in the covariance matrix.- Specified by:
- setSampleSizein interface- ICovarianceMatrix
- Parameters:
- sampleSize- the sample size to be set
 
- 
getNameGets the name of the covariance matrix.- Specified by:
- getNamein interface- DataModel
- Specified by:
- getNamein interface- ICovarianceMatrix
- Returns:
- a Stringobject
 
- 
setNameSets the name of the covariance matrix.Sets the name of the covariance matrix. - Specified by:
- setNamein interface- DataModel
- Specified by:
- setNamein interface- ICovarianceMatrix
- Parameters:
- name- the new name of the covariance matrix
 
- 
getKnowledgeGetter for the field knowledge.- Specified by:
- getKnowledgein interface- ICovarianceMatrix
- Specified by:
- getKnowledgein interface- KnowledgeTransferable
- Returns:
- the knowledge associated with this data.
 
- 
setKnowledgeSets the knowledge associated with the ICovarianceMatrix.Associates knowledge with this data. - Specified by:
- setKnowledgein interface- ICovarianceMatrix
- Specified by:
- setKnowledgein interface- KnowledgeTransferable
- Parameters:
- knowledge- the knowledge to set
 
- 
getSubmatrixgetSubmatrix. - Specified by:
- getSubmatrixin interface- ICovarianceMatrix
- Parameters:
- indices- an array of objects
- Returns:
- a submatrix of the covariance matrix with variables in the given order.
 
- 
getSubmatrixgetSubmatrix. - Parameters:
- indices- an array of objects
- dataRows- an array of objects
- Returns:
- a ICovarianceMatrixobject
 
- 
getSubmatrixgetSubmatrix. - Specified by:
- getSubmatrixin interface- ICovarianceMatrix
- Parameters:
- submatrixVarNames- a- Listobject
- Returns:
- a ICovarianceMatrixobject
 
- 
getSubmatrixgetSubmatrix. - Specified by:
- getSubmatrixin interface- ICovarianceMatrix
- Parameters:
- submatrixVarNames- an array of- Stringobjects
- Returns:
- a submatrix of this matrix, with variables in the given order.
 
- 
getValuepublic final double getValue(int i, int j) Retrieves the value from the covariance matrix at the specified row and column indices.- Specified by:
- getValuein interface- ICovarianceMatrix
- Parameters:
- i- the row index
- j- the column index
- Returns:
- the value at the specified indices in the matrix
 
- 
getValuepublic final double getValue(int i, int j, int[] rows) getValue. - Parameters:
- i- a int
- j- a int
- rows- an array of objects
- Returns:
- a double
 
- 
getSizepublic final int getSize()getSize. - Specified by:
- getSizein interface- ICovarianceMatrix
- Returns:
- the size of the square matrix.
 
- 
getMatrixGetter for the field matrix.- Specified by:
- getMatrixin interface- ICovarianceMatrix
- Returns:
- a copy of the covariance matrix.
 
- 
setMatrixSets the covariance matrix.- Specified by:
- setMatrixin interface- ICovarianceMatrix
- Parameters:
- matrix- the matrix to set
 
- 
getMatrixGetter for the field matrix.- Parameters:
- rows- an array of objects
- Returns:
- a Matrixobject
 
- 
selectSelects a specified variable in the covariance matrix.- Specified by:
- selectin interface- ICovarianceMatrix
- Parameters:
- variable- the node variable to be selected
 
- 
clearSelectionpublic final void clearSelection()clearSelection. - Specified by:
- clearSelectionin interface- ICovarianceMatrix
 
- 
isSelectedChecks if the specified node is selected in the covariance matrix.- Specified by:
- isSelectedin interface- ICovarianceMatrix
- Parameters:
- variable- the node to check for selection
- Returns:
- true if the node is selected, false otherwise
 
- 
getSelectedVariableNamesgetSelectedVariableNames. - Specified by:
- getSelectedVariableNamesin interface- ICovarianceMatrix
- Returns:
- a Listobject
 
- 
toStringPrints out the matrix
- 
isContinuouspublic boolean isContinuous()isContinuous. - Specified by:
- isContinuousin interface- DataModel
- Returns:
- true if the data model is continuous, false otherwise.
 
- 
isDiscretepublic boolean isDiscrete()isDiscrete. - Specified by:
- isDiscretein interface- DataModel
- Returns:
- true if the data model is discrete, false otherwise.
 
- 
isMixedpublic boolean isMixed()isMixed. 
- 
isVerbosepublic boolean isVerbose()isVerbose. - Returns:
- a boolean
 
- 
setVerbosepublic void setVerbose(boolean verbose) Setter for the field verbose.- Parameters:
- verbose- a boolean
 
- 
getSelectionReturns a submatrix based on the specified rows and columns.- Specified by:
- getSelectionin interface- ICovarianceMatrix
- Parameters:
- rows- an array of integers representing the row indices to be included in the selection.
- cols- an array of integers representing the column indices to be included in the selection.
- Returns:
- a Matrixobject containing the selected rows and columns.
 
- 
getSelectiongetSelection. - Parameters:
- rows- an array of objects
- cols- an array of objects
- dataRows- an array of objects
- Returns:
- a Matrixobject
 
- 
getVariableRetrieves a Node instance from the covariance matrix corresponding to the specified variable name.- Specified by:
- getVariablein interface- DataModel
- Specified by:
- getVariablein interface- ICovarianceMatrix
- Parameters:
- name- the name of the variable to retrieve
- Returns:
- the Node associated with the specified variable name
 
- 
copycopy. 
- 
setValuepublic void setValue(int i, int j, double v) Sets the value of the covariance matrix at the specified indices.- Specified by:
- setValuein interface- ICovarianceMatrix
- Parameters:
- i- the row index
- j- the column index
- v- the value to set at the specified indices
 
- 
removeVariablesRemoves variables from the covariance matrix, retaining only the variables specified in the provided list.- Specified by:
- removeVariablesin interface- ICovarianceMatrix
- Parameters:
- remaining- a list of variable names to retain in the covariance matrix.
 
 
-