  We present a hidden Markov model (HMM) for discovering stellar flares in
light curve data of stars. HMMs provide a framework to model time series data
that are not stationary; they allow for systems to be in different states at
different times and consider the probabilities that describe the switching
dynamics between states. In the context of stellar flares discovery, we exploit
the HMM framework by allowing the light curve of a star to be in one of three
states at any given time step: Quiet, Firing, or Decaying. This three state HMM
formulation is designed to enable straightforward identification of stellar
flares, their duration, and associated uncertainty. This is crucial for
estimating the flare's energy, and is useful for studies of stellar flare
energy distributions. We combine our HMM with a celerite model that accounts
for quasi periodic stellar oscillations. Through an injection recovery
experiment, we demonstrate and evaluate the ability of our method to detect and
characterize flares in stellar time series. We also show that the proposed HMM
flags fainter and lower energy flares more easily than traditional sigma
clipping methods. Lastly, we visually demonstrate that simultaneously
conducting detrending and flare detection can mitigate biased estimations
arising in multistage modelling approaches. Thus, this method paves a new way
to calculating stellar flare energy. We conclude with an example application to
one star observed by TESS, showing how the HMM compares with sigma clipping
when using real data.
