ποΈ corr-solver
Correlation Solver Python Code
This code defines a class called mle_oracle which is designed to solve a maximum likelihood estimation problem. The purpose of this code is to find the best parameters for a statistical model based on observed data, while satisfying certain constraints.
The mle_oracle class takes two inputs when initialized: Sigma and Y. Sigma represents a covariance matrix, which describes how different variables in a dataset are related to each other. Y is a biased sample covariance matrix, which is an estimate of the true covariance based on observed data.
The main output of this class is produced by the assess_optim method. This method takes two inputs: x (a set of coefficients) and t (the best optimal value found so far). It returns a tuple containing information about whether the current solution is feasible and optimal, along with some additional values used in the optimization process.
To achieve its purpose, the code uses a technique called linear matrix inequality (LMI) optimization. It creates two LMI oracles (lmi0 and lmi) which are used to check if the current solution satisfies certain constraints. The assess_optim method first checks if the solution is feasible using these oracles. If itβs not feasible, it returns information about why itβs not feasible.
If the solution is feasible, the method then calculates a value f1, which represents the objective function of the maximum likelihood estimation problem. This calculation involves matrix operations like inversion, multiplication, and calculating traces and determinants. The method also computes a gradient g, which indicates how the objective function changes with respect to small changes in the input x.
Finally, the method compares the calculated f1 with the input t to determine if a better solution has been found. If f1 is better than t, it returns this new value along with the gradient. Otherwise, it returns information that can be used to continue the optimization process.
The important logic flows in this code include the feasibility checks, the calculation of the objective function and its gradient, and the comparison of the current solution with the best known solution. The data transformations mainly involve matrix operations on the input covariance matrices.
Overall, this code provides a way to solve a complex statistical optimization problem by iteratively improving a solution while ensuring it satisfies certain constraints. Itβs a building block that would typically be used as part of a larger optimization algorithm.
Dependencies
- luk036/lds-gen (>=3.10)
- luk036/ellalgo
- numpy
- scipy
β¨ Features
- Explore convexity
π οΈ Installation
- The core corr-solver depends on the
lds-gen
andellalgo
modules.
π See also
π Note
This project has been set up using PyScaffold 4.0.2. For details and usage information on PyScaffold see https://pyscaffold.org/.