Skip to content

Repeated logic in several modules #480

Open
@QBatista

Description

@QBatista

There are several existing classes that appear to be reproducing closely related functionalities, thus violating the "Don't Repeat Yourself" principle which is outlined in one of the lectures in one of the lectures. For instance, all the following modules include a form of a linear state transition equation

  • robustlq.py
  • lss.py
  • lqnash.py
  • lqcontrol.py
  • army.py
  • kalman.py

#476 introduces yet another class which falls into this group. The ARMA class has a simulation method, the LQ class has a compute_sequence method and the LinearStateSpace has a simulate method. Besides, both Kalman and LQ have stationary_values methods that use solve_discrete_riccati. Similarly, LinearStateSpace and ARMA have impulse_response methods.

Therefore, we might want to consider refactoring these classes, potentially into a sub-package. Besides avoiding repetition and making it easier to understand how these classes are connected, another benefit would be that features added to a base class would directly propagate to derived classes.

As @thomassargent30 pointed out, this refactoring is bound to take some time and require a person who is familiar with all of the lectures that use these classes. Considering that some new lectures which use these classes are currently in production, @jstac suggested that we hold off on a major reorganization and instead consider piecemeal improvements. Specifically, we could add a linear_gaussian module that contains:

  1. a jitted function that simulates vector-valued Gaussian processes, and

  2. a jitted function that returns the stationary mean and variance.

Does anyone have any additional thoughts or suggestions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions