Package edu.cmu.tetrad.data
Interface ICovarianceMatrix
- All Superinterfaces:
DataModel
,KnowledgeTransferable
,Serializable
,TetradSerializable
,VariableSource
- All Known Implementing Classes:
CorrelationMatrix
,CorrelationMatrixOnTheFly
,CovarianceMatrix
,CovarianceMatrixOnTheFly
Interface for covariance matrices. Implemented in different ways. See implementations.
- Version:
- $Id: $Id
- Author:
- josephramsey
-
Field Summary
Fields inherited from interface edu.cmu.tetrad.data.DataModel
serialVersionUID
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the current selection of variables in the covariance matrix.int
Retrieves the dimension of the covariance matrix.Retrieves the knowledge associated with the ICovarianceMatrix.Retrieves the covariance matrix.getName()
Gets the name of the covariance matrix.int
Retrieves the sample size used in the covariance matrix.Retrieves a list of names of the currently selected variables.getSelection
(int[] rows, int[] cols) Returns a submatrix based on the specified rows and columns.int
getSize()
Retrieves the size of the matrix.getSubmatrix
(int[] indices) Returns a submatrix of the covariance matrix, including only the specified variables.getSubmatrix
(String[] submatrixVarNames) Returns a submatrix of the covariance matrix, including only the specified variables.getSubmatrix
(List<String> submatrixVarNames) Returns a submatrix of the covariance matrix, including only the specified variables.double
getValue
(int i, int j) Retrieves the value from the covariance matrix at the specified row and column indices.getVariable
(String name) Retrieves a Node instance from the covariance matrix corresponding to the specified variable name.getVariableName
(int index) Retrieves the name of the variable at the specified index from the covariance matrix.Retrieves the list of names of the variables in the covariance matrix.Retrieves the list of Node variables for the covariance matrix.boolean
isSelected
(Node variable) Checks if the specified node is selected in the covariance matrix.void
removeVariables
(List<String> remaining) Removes variables from the covariance matrix, retaining only the variables specified in the provided list.void
Selects a specified variable in the covariance matrix.void
setKnowledge
(Knowledge knowledge) Sets the knowledge associated with the ICovarianceMatrix.void
Sets the covariance matrix.void
Sets the name of the covariance matrix.void
setSampleSize
(int sampleSize) Sets the sample size used in the covariance matrix.void
setValue
(int i, int j, double v) Sets the value of the covariance matrix at the specified indices.void
setVariables
(List<Node> variables) Sets the list of Node variables for the covariance matrix.toString()
Renders the covariance matrix as a string representation.Methods inherited from interface edu.cmu.tetrad.data.DataModel
copy, isContinuous, isDiscrete, isMixed
-
Method Details
-
getVariables
Retrieves the list of Node variables for the covariance matrix.- Specified by:
getVariables
in interfaceVariableSource
- Returns:
- a list of Node objects representing the variables in the covariance matrix.
-
setVariables
-
getVariableNames
Retrieves the list of names of the variables in the covariance matrix.- Specified by:
getVariableNames
in interfaceVariableSource
- Returns:
- a list of strings representing the names of the variables.
-
getVariableName
Retrieves the name of the variable at the specified index from the covariance matrix.- Parameters:
index
- the index of the variable whose name is to be retrieved- Returns:
- the name of the variable at the specified index
-
getDimension
int getDimension()Retrieves the dimension of the covariance matrix.- Returns:
- the dimension of the covariance matrix as an integer
-
getSampleSize
int getSampleSize()Retrieves the sample size used in the covariance matrix.- Returns:
- the sample size as an integer
-
setSampleSize
void setSampleSize(int sampleSize) Sets the sample size used in the covariance matrix.- Parameters:
sampleSize
- the sample size to be set
-
getName
-
setName
-
getKnowledge
Knowledge getKnowledge()Retrieves the knowledge associated with the ICovarianceMatrix.- Specified by:
getKnowledge
in interfaceKnowledgeTransferable
- Returns:
- the Knowledge object representing the associated knowledge
-
setKnowledge
Sets the knowledge associated with the ICovarianceMatrix.- Specified by:
setKnowledge
in interfaceKnowledgeTransferable
- Parameters:
knowledge
- the knowledge to set
-
getSubmatrix
Returns a submatrix of the covariance matrix, including only the specified variables.- Parameters:
indices
- an array of integers specifying the indices of the variables to include in the submatrix- Returns:
- a submatrix of the covariance matrix that includes only the specified variables
-
getSubmatrix
Returns a submatrix of the covariance matrix, including only the specified variables.- Parameters:
submatrixVarNames
- a list of strings specifying the variable names to include in the submatrix- Returns:
- a submatrix of the covariance matrix that includes only the specified variables
-
getSubmatrix
Returns a submatrix of the covariance matrix, including only the specified variables.- Parameters:
submatrixVarNames
- an array of strings specifying the variable names to include in the submatrix- Returns:
- a submatrix of the covariance matrix that includes only the specified variables
-
getValue
double getValue(int i, int j) Retrieves the value from the covariance matrix at the specified row and column indices.- Parameters:
i
- the row indexj
- the column index- Returns:
- the value at the specified indices in the matrix
-
getSize
int getSize()Retrieves the size of the matrix.- Returns:
- the size of the square matrix.
-
getMatrix
Matrix getMatrix()Retrieves the covariance matrix.- Returns:
- a Matrix object representing the covariance matrix
-
setMatrix
-
select
Selects a specified variable in the covariance matrix.- Parameters:
variable
- the node variable to be selected
-
clearSelection
void clearSelection()Clears the current selection of variables in the covariance matrix. This method resets any selected variables to their default unselected state. -
isSelected
Checks if the specified node is selected in the covariance matrix.- Parameters:
variable
- the node to check for selection- Returns:
- true if the node is selected, false otherwise
-
getSelectedVariableNames
-
toString
-
getVariable
Retrieves a Node instance from the covariance matrix corresponding to the specified variable name.- Specified by:
getVariable
in interfaceDataModel
- Parameters:
name
- the name of the variable to retrieve- Returns:
- the Node associated with the specified variable name
-
setValue
void setValue(int i, int j, double v) Sets the value of the covariance matrix at the specified indices.- Parameters:
i
- the row indexj
- the column indexv
- the value to set at the specified indices
-
removeVariables
-
getSelection
Returns a submatrix based on the specified rows and columns.- 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
Matrix
object containing the selected rows and columns.
-