milosgajdos/go-estimate

interface definitions with nomenclature

soypat opened this issue · 2 comments

It would be of great use if interfaces where arguments are ambiguous, for example Observer and Filter, named their arguments according to control theory typical nomenclature.

This is current interface definition

// Filter is a dynamical system filter.
type Filter interface {
	// Predict estimates the next internal state of the system
	Predict(mat.Vector, mat.Vector) (Estimate, error)
	// Update updates the system state based on external measurement
	Update(mat.Vector, mat.Vector, mat.Vector) (Estimate, error)
}

// Propagator propagates internal state of the system to the next step
type Propagator interface {
	// Propagate propagates internal state of the system to the next step
	Propagate(mat.Vector, mat.Vector, mat.Vector) (mat.Vector, error)
}

// Observer observes external state (output) of the system
type Observer interface {
	// Observe observes external state of the system
	Observe(mat.Vector, mat.Vector, mat.Vector) (mat.Vector, error)
}

Problems with this definition include:

  • All arguments are mat.Vector. What convention is being used?
  • Comments do not help either. Overall lackluster documentation

Other interfaces with this problem:

  • filter.DiscreteModel. This one is fixed easy: StateMatrix() (A mat.Matrix). A,B,C and D matrices are standard nomenclature for these matrices

Possible solutions

Below is a mix of adding a little bit of documentation + naming the variables.

type Filter interface {
	// Predict estimates the next internal state of the system. x is state, u are inputs
	Predict(x,u mat.Vector) (filter.Estimate, error)
	// Update updates the system state based on external measurement. x is state, u are inputs, z is the measurement
	Update(x, u, z mat.Vector) (filter.Estimate, error) 
}

If you give me the all-clear I can try fixing it tonight and PRing. This and #7

Happy to accept a PR for this. This sounds like a great idea.