pytorch_hamiliton_unittest

Validate PyTorch Markov Regime-Switching training and Hamilton-filter tensor invariants.

Updated May 21, 2026
One-click install
npx skills add https://github.com/ulf1/trading-regime --skill pytorch-hamiliton-unittest
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytorch_hamiliton_unittest
Source: https://github.com/ulf1/trading-regime/tree/main/.agent/skills/899_pytorch_hamiliton_unittest
Command: npx skills add https://github.com/ulf1/trading-regime --skill pytorch-hamiliton-unittest

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) components.

What problem does it solve?

It prevents subtle mathematical and tensor-shape regressions in vectorized PyTorch Markov Regime-Switching models by enforcing domain constraints and probabilistic invariants during automated unit testing.

Core Features & Use Cases

  • Reparameterization validation: Ensures raw parameters map into safe domains, including strictly positive standard deviations and properly normalized, non-negative transition probabilities.
  • Hamilton filter invariants: Verifies that filtered state assignment probabilities are well-formed at every time step (non-negative and summing to 1.0).
  • Regime identifiability checks: Confirms permutation equivariance when sorting regime states, including consistent reordering across means, sigma parameters, and multi-dimensional transition tensors.
  • Input validation: Asserts expected tensor dimensions and raises errors for mismatched inputs, protecting downstream training and inference.

Quick Start

Use the pytorch_hamiliton_unittest skill to run the unit tests in examples/test_mrs_model.py and verify constraint, sorting, forward-pass, and prediction-step behaviors for your Markov Regime-Switching implementation.

Frequently Asked Questions about pytorch_hamiliton_unittest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test Hamilton filter probability invariants in a PyTorch Markov regime-switching model?

To test Hamilton filter probability invariants in PyTorch, use Pytest to assert that filtered state probabilities are non-negative and sum to 1.0 at every time step during forward-pass inference. This ensures your regime-switching model maintains valid distributions across batched time-series inputs.

What is the best way to validate tensor shapes and parameter reparameterization for PyTorch Markov regime-switching training?

Validating tensor shapes and parameter reparameterization for PyTorch Markov regime-switching training involves asserting expected tensor dimensions for batched inputs and enforcing domain constraints, such as strictly positive sigma values and normalized, non-negative transition matrix rows.

How do I check regime identifiability sorting consistency across means, sigmas, and transition tensors?

Checking regime identifiability sorting consistency requires verifying that identical permutations apply across means, sigma parameters, and 3D transition tensors. This permutation equivariance ensures sorted regime states remain mathematically equivalent during vectorized PyTorch operations.

Can I use Pytest to catch tensor-shape regressions in vectorized PyTorch Hamilton filter inference?

Yes, you can use Pytest to catch tensor-shape regressions in vectorized PyTorch Hamilton filter inference by asserting expected tensor dimensions for batched time-series inputs and raising errors for mismatched inputs during next-step prediction.

Why does my Markov regime-switching model fail probability distribution constraints during unit testing?

Your Markov regime-switching model fails probability distribution constraints during unit testing when transition rows do not sum to 1.0, sigma values drop to zero or below, or filtered probabilities violate non-negativity and normalization rules across time steps.

What constraints should I enforce when unit testing a PyTorch Markov regime-switching model?

When unit testing a PyTorch Markov regime-switching model, enforce that sigma is strictly positive, transition rows are non-negative and sum to 1.0, filtered probabilities sum to 1.0 per time step, and identifiability sorting applies identical permutations across all parameter tensors.