## 3 Methods
### Facial Expression Recognition
: _As \(t\rightarrow\infty\), the posterior mean estimate \(\hat{\theta}_{i}\) converges to the true reward probability \(\mu_{i}\)._

Using Bayesian inference, the posterior probability density is given by

\[P(\theta_{i}|x_{i,1},\ldots,x_{i,n_{i}})=\frac{\theta_{i}^{\alpha_{i}^{\prime }-1}(1-\theta_{i})^{\beta_{i}^{\prime}-1}}{B(\alpha_{i}^{\prime},\beta_{i}^{ \prime})}. \tag{1}\]

We apply the Law of Large Numbers,

\[\hat{\theta}_{i}=\frac{\alpha_{i}^{\prime}}{\alpha_{i}^{\prime}+\beta_{i}^{ \prime}}\rightarrow\mu_{i}, \tag{2}\]

where \(\mu_{i}\) is the true probability of stimulus \(s_{i}\) improving engagement. This result confirms that the posterior estimate is an unbiased estimator of the true probability and, thus, the BIFL algorithm adapts optimally over time. #### 3.3.3 Exploration-Exploitation Trade-Off in BIFL

To balance exploration and exploitation, BIFL employs the Upper Confidence Bound (UCB) approach, which selects the stimulus with the highest expected reward adjusted by an exploration term. The expected stimulus reward \(s_{i}\) is given by the posterior mean:

\[\hat{\theta}_{i}=\frac{\alpha_{i}^{\prime}}{\alpha_{i}^{\prime}+\beta_{i}^{ \prime}}. \tag{3}\]

**Lemma 1**. : _The probability of selecting a suboptimal stimulus decreases over time as_

\[P(\theta_{i}>\theta_{j})\approx 1-O\bigg{(}\frac{1}{t}\bigg{)}. \tag{4}\]

Proof. : Since the posterior distribution follows \(\theta_{i}\sim Beta(\alpha_{i},\beta_{i})\), the probability of selecting \(s_{i}\) over \(s_{j}\) follows Thompson Sampling:

\[P(\theta_{i}>\theta_{j})=\int_{0}^{1}P(\theta_{i}>\theta_{j}|x)P(x)dx. \tag{5}\]

As \(t\rightarrow\infty\), \(P(\theta_{i}>\theta_{j})\) approaches 1, ensuring that the probability of selecting an inferior stimulus diminishes over time. Thus, BIFL dynamically adapts the stimulus selection process, optimizing engagement through feedback learning. #### 3.3.4 Stimulus Selection and Decision-Making

At each iteration, BIFL samples the posterior distribution for each stimulus and selects the one with the highest estimated reward: \(s^{*}=\arg\max_{s_{i}}\theta_{i}\). To further balance between exploration and exploitation, the system applies a UCB strategy:

\[s^{*}=\arg\max_{s_{i}}\left(\hat{\theta}_{i}+\sqrt{\frac{\beta_{0}+\alpha_{0} }{\beta_{i}^{\prime}+\alpha_{i}^{\prime}}}\right), \tag{6}\]

where \(\beta_{0}+\alpha_{0}\) represents the prior sample size, influencing the trade-off between exploring new stimuli and exploiting known effective stimuli. #### 3.3.5 Incremental Learning in BIFL

**Theorem 2**. : _As new observations are collected, BIFL updates its prior beliefs using Bayesian updating, refining stimulus selection over time._

Proof. : Given \(n_{i}\) observations of a stimulus \(s_{i}\), where \(x_{i,1},...,x_{i,n_{i}}\) are the observed engagement improvements, the posterior parameters update as

\[\alpha_{i}^{\prime}=\alpha_{i}+\sum_{j=1}^{n_{i}}x_{i,j},\quad\beta_{i}^{ \prime}=\beta_{i}+n_{i}-\sum_{j=1}^{n_{i}}x_{i,j}. \tag{7}\]

Since the Beta distribution acts as a conjugate prior for the Bernoulli likelihood function, the posterior maintains a Beta form: \(\theta_{i}|x_{i,1},...,x_{i,n_{i}}\sim Beta(\alpha_{i}^{\prime},\beta_{i}^{ \prime})\). Thus, BIFL continuously refines its belief about the effectiveness of each stimulus, ensuring optimal adaptation. Overall Workflow of BIFL

BIFL follows these steps:

1. Prior beliefs: Assume a Beta prior for each stimulus. 2. Select stimulus \(s^{*}\) using Thompson Sampling or UCB. 3. Feedback: Record the cognitive response \(x_{i,t}\). 4. Beliefs: Adjust \(\alpha_{i}\) and \(\beta_{i}\) using Bayesian updating. 5. Repeat: Continuously improve stimulus selection. In short, BIFL provides an adaptive mechanism for selecting optimal stimuli in real time based on immediate feedback. The integration of Bayesian inference and MAB theory ensures continuous learning while maintaining an optimal balance between exploration and exploitation. This approach enables highly personalized cognitive training, optimizing engagement for each individual user.