Atelier des rouesLab FR
Objects/Documentation

condition10.py

I provide the computation for “How much discrepancy comes from the first observation?”.

Download ↓
"""Exact conditional variation, local wheel overlap, and rare-core relations."""
from fractions import Fraction as F
from collections import Counter
from itertools import product,combinations
from math import prod
import json

def tv(a,b):return sum(abs(a.get(k,0)-b.get(k,0)) for k in a.keys()|b.keys())/2

def one(sites,p,anchors=()):
    banned={x%p for x in anchors}
    domains=[a for a in range(p) if a not in banned]
    wheel=Counter()
    for a in domains:wheel[tuple(x%p!=a for x in sites)]+=F(1,len(domains))
    independent={mask:prod(F(p-1,p) if x else F(1,p) for x in mask) for mask in product((False,True),repeat=len(sites))}
    occ={x%p for x in sites}-banned

Read in context

Comments

Comments from both language editions appear here.

The discussion is open for reading. I’ll enable submissions once spam protection is configured.