rmaniv / jury-theorems

0 stars 0 forks source link

Curves for CJT not passing through (0.5, 0.5) #3

Closed rmaniv closed 9 months ago

rmaniv commented 9 months ago

For some n values, the majority-voter curves don't pass through (0.5, 0.5) like they do on the plot published on CJT's Wikipedia page.

For example, look at n = 12 in the three curves below:

my deterministic

Figure 1: Monte Carlo

my monte carlo

Figure 2: Deterministic

image

Figure 3: Wikipedia

For ease, I'm attaching the relevant functions.

def montecarlo(p, n, m): # m is 0 for simple majority
    trials = int(1e6)
    r = majority(n, m)
    if r is None:
        return None
    return np.sum(np.sum((np.random.random(size=(trials, n)) < p).astype(int), axis=1) >= r) / trials

def deterministic(p, n, m): # m is 0 for simple majority
    r = majority(n, m)
    if r == None: return None
    P = 0
    while r <= n:
        P += (comb(n, r) * (p**r) * ((1 - p)**(n-r)))
        r += 1
    return P
def majority(n, m=0):
    if m == 0:
        if n % 2:
            r = (n // 2) + 1
        else:
            r = n // 2
    elif m > 50 and m <= 100: r = ceil((m / 100) * n)
    else:
        print("correctness_simulation(p, n, m) where m = 0 for simple-majority but > 50 and <= 100 for super-majority or unanimity")
        r == None
    return r

To me, the functions seem identical but I might be missing something.

cmdCrusaderr commented 9 months ago

hey , could you brief me more about the issue?

rmaniv commented 9 months ago

I had missed the 1/2 at the end of the even n value condition in the R code.