module statmech
function compute_energy
compute_energy(X: Tensor, params: Dict[str, Tensor]) → Tensor
Compute the DCA energy of the sequences in X.
Args:
X
(torch.Tensor): Sequences in one-hot encoding format.params
(Dict[str, torch.Tensor]): Parameters of the model.
Returns:
torch.Tensor
: DCA Energy of the sequences.
function compute_log_likelihood
compute_log_likelihood(
fi: Tensor,
fij: Tensor,
params: Dict[str, Tensor],
logZ: float
) → float
Compute the log-likelihood of the model.
Args:
fi
(torch.Tensor): Single-site frequencies of the data.fij
(torch.Tensor): Two-site frequencies of the data.params
(Dict[str, torch.Tensor]): Parameters of the model.logZ
(float): Log-partition function of the model.
Returns:
float
: Log-likelihood of the model.
function enumerate_states
enumerate_states(L: int, q: int, device: device = device(type='cpu')) → Tensor
Enumerate all possible states of a system of L sites and q states.
Args:
L
(int): Number of sites.q
(int): Number of states.device
(torch.device, optional): Device to store the states. Defaults to "cpu".
Returns:
torch.Tensor
: All possible states.
function compute_logZ_exact
compute_logZ_exact(all_states: Tensor, params: Dict[str, Tensor]) → float
Compute the log-partition function of the model.
Args:
all_states
(torch.Tensor): All possible states of the system.params
(Dict[str, torch.Tensor]): Parameters of the model.
Returns:
float
: Log-partition function of the model.
function compute_entropy
compute_entropy(chains: Tensor, params: Dict[str, Tensor], logZ: float) → float
Compute the entropy of the DCA model.
Args:
chains
(torch.Tensor): Chains that are supposed to be an equilibrium realization of the model.params
(Dict[str, torch.Tensor]): Parameters of the model.logZ
(float): Log-partition function of the model.
Returns:
float
: Entropy of the model.
function iterate_tap
iterate_tap(
mag: Tensor,
params: Dict[str, Tensor],
max_iter: int = 500,
epsilon: float = 0.0001
)
Iterates the TAP equations until convergence.
Args:
mag
(torch.Tensor): Initial magnetizations.params
(Dict[str, torch.Tensor]): Parameters of the model.max_iter
(int, optional): Maximum number of iterations. Defaults to 2000.epsilon
(float, optional): Convergence threshold. Defaults to 1e-6.
Returns:
torch.Tensor
: Fixed point magnetizations of the TAP equations.
This file was automatically generated via lazydocs.