RicardoSantos

FunctionProbabilityViterbi

RicardoSantos Wizard Updated   
Library "FunctionProbabilityViterbi"
The Viterbi Algorithm calculates the most likely sequence of hidden states *(called Viterbi path)*
that results in a sequence of observed events.

viterbi(observations, transitions, emissions, initial_distribution)
  Calculate most probable path in a Markov model.
  Parameters:
    observations (int): array<int> . Observation states data.
    transitions (matrix<float>): matrix<float> . Transition probability table, (HxH, H:Hidden states).
    emissions (matrix<float>): matrix<float> . Emission probability table, (OxH, O:Observed states).
    initial_distribution (float): array<float> . Initial probability distribution for the hidden states.
  Returns: array<int>. Most probable path.
Release Notes:
v2 minor update.
Release Notes:
Minor update: console library version.
Release Notes:
v4 - added some error overloads with custom message to handle some cases.
Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House Rules.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this library?

Copy the following line and paste it in your script.