Kevin HY Hau - Hello World 👋


Chapter 1 - Kevin Hau's k-Bit Recurrence Model

Shiny App - k-Bit Recurrence Model


Objective:

This algorithm model a stochastic process that combines the forward-branching structure of a binomial tree with the memory-retaining dynamics of a recurrent neural network (similar to Hopfield network when historical step (k) = 3), while computing expected values at every step under binary (0/1) outcomes.

Applications:


Instructions:


See it move:

Pick a picture below. Each one shows one idea of the model (use the sliders to change it). The numbers in the animation are illustrative, so you can see the shape of the idea; the app below uses your own data.

In five steps:

  1. Each step is a 0 or a 1. Paid or not paid, event or no event. Every step splits into two branches, like a binomial tree.
  2. Remember the last k steps. The last k bits form a small pattern, which is the state (k = 3 gives 8 states). A normal tree only remembers the last step; this model remembers k.
  3. The state sets the odds. The pattern picks the chance that the next bit is a 1. Memory strength 0 means no memory (a plain tree); higher means the past matters more.
  4. Add up the paths. Different 0/1 paths that end with the same number of payments after the same number of steps are combined into one chance (tab 2).
  5. Push expected values forward. Instead of simulating thousands of random paths, it moves the expected number of people through the states, one step at a time, so the forecast is exact and fast.

Details:

In a binomial tree, each node’s probability depends only on the immediately previous state. Here, the transition probability at step k is derived from a grouped summary of multiple earlier steps—effectively treating the history as a compact state vector whose influence decays or aggregates in a controlled manner.

This is similar to the recurrent connections in a Hopfield network, where the network’s energy landscape stores and retrieves patterns from past activations. However, unlike Hopfield neural network (which typically performs deterministic or probabilistic retrieval), the algorithm injects a forward-looking expected-value layer.

This expectation is propagated forward, turning the process into a hybrid recurrent stochastic process that remembers past configurations while maintaining an analytically tractable martingale-like property.


Try it

The app is hosted on shinyapps.io. If the box below stays blank, use the button: it opens the same app in its own tab.

Open the app in a new tab ↗


TO DO (based on funding):