\begin{algorithm}
\caption{General strategy for permutation testing by betting} \label{alg:general}
 \hspace*{\algorithmicindent} \textbf{Input:} Sequence of test statistics $Y_0,Y_1, Y_2, \ldots$.\\
 \textbf{Optional Input:} Stopping rule $\mathcal S$, potentially data-dependent and decided on the fly.\\
 \hspace*{\algorithmicindent} \textbf{Output:} E-process $(W_t)_{t \geq 1}$, and p-process $(1/\sup_{s \leq t} W_s)_{t \geq 1}$.\\
 \textbf{Optional output:} Stopping time $\tau$, e-value $W_{\tau}$, p-value $1/\sup_{s \leq \tau} W_s$.
\begin{algorithmic}[1]
\State $W_0 = 1$ 
\For{$t=1,2,...$}
\State Choose betting strategy $B_t=(B_t(1),\ldots,B_t(t+1))$ with $\sum_{r=1}^{t+1} B_t(r)=t+1$  
\State Reveal $R_t$
\State $W_t = W_{t-1} \cdot B_t(R_t)$ 
\If{$\mathcal S(R_1,\ldots,R_t)=\text{stop}$} 
    \State $\tau=t$
    \State \Return $\tau, W_{\tau}, (\max_{s=1,\ldots,\tau} W_s)^{-1}$
\EndIf
\EndFor
\end{algorithmic}
\end{algorithm}

\begin{algorithm}
\caption{General strategy for permutation testing by betting} \hspace*{\algorithmicindent} \textbf{Input:} Sequence of test statistics $Y_0,Y_1, Y_2, \ldots$.\\
\textbf{Optional Input:} Stopping rule $\mathcal S$, potentially data-dependent and decided on the fly.\\
\hspace*{\algorithmicindent} \textbf{Output:} E-process $(W_t)_{t \geq 1}$, and p-process $(1/\sup_{s \leq t} W_s)_{t \geq 1}$.\\
\textbf{Optional output:} Stopping time $\tau$, e-value $W_{\tau}$, p-value $1/\sup_{s \leq \tau} W_s$.
\begin{algorithmic}
[1]
\State $W_0 = 1$
\For{$t=1,2,...$}
\State Choose betting strategy $B_t=(B_t(1),\ldots,B_t(t+1))$ with $\sum_{r=1}^{t+1} B_t(r)=t+1$
\State Reveal $R_t$
\State $W_t = W_{t-1} \cdot B_t(R_t)$
\If{$\mathcal S(R_1,\ldots,R_t)=\text{stop}$}
\State $\tau=t$
\State \Return $\tau, W_{\tau}, (\max_{s=1,\ldots,\tau} W_s)^{-1}$
\EndIf
\EndFor
\end{algorithmic}
\end{algorithm}
{
    "title": "sequential monte-carlo testing by betting",
    "id": "2401.07365",
    "abstract": "in a monte-carlo test, the observed dataset is fixed, and several resampled or permuted versions of the dataset are generated in order to test a null hypothesis that the original dataset is exchangeable with the resampled/permuted ones. sequential monte-carlo tests aim to save computational resources by generating these additional datasets sequentially one by one, and potentially stopping early. while earlier tests yield valid inference at a particular prespecified stopping rule, our work develops a new anytime-valid monte-carlo test that can be continuously monitored, yielding a p-value or e-value at any stopping time possibly not specified in advance. despite the added flexibility, it significantly outperforms the well-known method by besag and clifford, stopping earlier under both the null and the alternative without compromising power. the core technical advance is the development of new test martingales (nonnegative martingales with initial value one) for testing exchangeability against a very particular alternative. these test martingales are constructed using new and simple betting strategies that smartly bet on the relative ranks of generated test statistics. the betting strategies are guided by the derivation of a simple log-optimal betting strategy, have closed form expressions for the wealth process, provable guarantees on resampling risk, and display excellent power in practice.",
    "categories": "stat.me",
    "doi": "",
    "created": "2024-01-14",
    "updated": "2024-02-18",
    "authors": [
        "lasse fischer",
        "aaditya ramdas"
    ],
    "affiliation": [],
    "url": "https://arxiv.org/abs/2401.07365"
}
{
    "ToxicityFilter": {
        "text_to_toxicity_attributes": {
            "main.bib": {
                "toxicity_score": 0.013320025,
                "severe_toxicity_score": 0.0018596649,
                "identity_attack_score": 0.003366805,
                "insult_score": 0.008044879,
                "profanity_score": 0.018187506,
                "threat_score": 0.0067186756,
                "sexually_explicit_score": 0.01710338,
                "flirtation_score": 0.24059573
            },
            "main.toc": {
                "toxicity_score": 0.00719407,
                "severe_toxicity_score": 0.0007915497,
                "identity_attack_score": 0.0019608864,
                "insult_score": 0.0064488696,
                "profanity_score": 0.012961143,
                "threat_score": 0.006537435,
                "sexually_explicit_score": 0.009672256,
                "flirtation_score": 0.31018758
            },
            "main.tex": {
                "toxicity_score": 0.010304171,
                "severe_toxicity_score": 0.0010061264,
                "identity_attack_score": 0.0032558115,
                "insult_score": 0.007189874,
                "profanity_score": 0.014259194,
                "threat_score": 0.0072882893,
                "sexually_explicit_score": 0.0108517995,
                "flirtation_score": 0.18085068
            },
            "main.bbl": {
                "toxicity_score": 0.011937759,
                "severe_toxicity_score": 0.0011348724,
                "identity_attack_score": 0.0040142676,
                "insult_score": 0.007531876,
                "profanity_score": 0.0147374235,
                "threat_score": 0.007547205,
                "sexually_explicit_score": 0.011795434,
                "flirtation_score": 0.20725061
            },
            "main.out": {
                "toxicity_score": 0.006440107,
                "severe_toxicity_score": 0.0011205673,
                "identity_attack_score": 0.0012024303,
                "insult_score": 0.0060783676,
                "profanity_score": 0.015591404,
                "threat_score": 0.005935457,
                "sexually_explicit_score": 0.014449406,
                "flirtation_score": 0.34677386
            }
        },
        "reason": null
    }
}
{
    "num_done": {
        "figure": 0,
        "algorithm": 2,
        "plot": 0
    }
}
{
    "NonTrivialRenderingFilter": {
        "white_pixels_ratio": 95.37701168694319,
        "hash": "3f007f3f0faf8f3f",
        "most_frequent_color_ratio": 95.37701168694319
    }
}