Skip to content

Comments

betting_mart should not ignore stalls#107

Open
JohnLCaron wants to merge 1 commit intopbstark:mainfrom
JohnLCaron:removeIgnoreStall
Open

betting_mart should not ignore stalls#107
JohnLCaron wants to merge 1 commit intopbstark:mainfrom
JohnLCaron:removeIgnoreStall

Conversation

@JohnLCaron
Copy link

This line of code in betting_mart intervenes when a term gets close to 0, by changing the term to 1, effectively ignoring the stall.

This happens when x = 0 and lamda is ~= 1/mj ~= 2. The effect is to ignore x = 0, which is the worst assort value; ignoring it makes the audit invalid I think.

A better way to prevent stalls is to limit the value of lamda to < 1/mj.
Im planning on studying how much less it should be, since keeping lamda close to 2 will optimize the no error case.
Its possible that your bet function already enforces lamda < 1/mj, in which case you would never see this problem.

However, I was naively using a port of Nonneg_mean.optimal_comparison() for the OneAudit bet function, and was getting suspiciously good results. Once I found that problem, the results were less optimal.

In any case I cant see any good reason that the line should be in there.

@spertus
Copy link
Collaborator

spertus commented Dec 19, 2025

It looks like, from the comments, that line was supposed to set the terms in the P-value sequence equal to 1, which (I think) is correct logic. But instead it sets the terms of the martingale itself equal to 1, which I agree it shouldn't do. I'm wondering if anything is lost by removing the line entirely.

In assuming a small rate of 2-vote-overstatements, Nonneg_mean.optimal_comparison() defaults to a bet slightly below the maximal bet, so the martingale should never go completely broke even if a 0 (e.g., a 2-vote-overstatement) is observed.

@JohnLCaron
Copy link
Author

i agreee if 2-vote overstatement rate > 0, lamda < 1/mj in optimal_comparison() and you should never see the problem.

I was exploring "what if we assume there are no errors and adapt as we see them?" betting strategy and inadvertantly triggered it.

Im not sure why the pvalue goes to 1 when the martingale vanishes?

@JohnLCaron
Copy link
Author

I see that youve already made all your martingale values in

 np.cumprod(1 + lam * (x - m))

so modifying one of the terms doesnt affect subsequent ones.

Now I see how that changes everything. Im doing "one sample at a time" and terminating when p < risk.
Sorry, Im not used to python array processing.

Still not sure why pvalue = 1 when mart = 0.

@pbstark
Copy link
Owner

pbstark commented Jan 2, 2026 via email

@JohnLCaron
Copy link
Author

Ok, I see. Setting the terms to 1 when the martingale vanishes is a way to set pvalue to 1. However, perhaps its misleading when you are returning the martingale sequence, so you might consider only doing so when out = "p-values".

I have not been setting 1.0 as the maximum value of pvalue. Ive really been using it to mean 1/term, which may be greater than 1. The only place that comes into play I think is for multi-round audits. But subsequent rounds just start from where the previous ones stop, and 1/term gives you the sense of "how much further there is to go". In practice, the rounds are independent of each other, that is, they start from pvalue = 1 and replicate the previous round exactly up to the previous sample size, and then keep going with the new samples.

Ive been assuming that I cant use the measured error rates from the previous round when auditing, because it would be a form of "peeking ahead". However I can use them when estimating the next round's sample size.

If any of those assumptions seem wrong, your thoughts would be appreciated.

-- John

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants