Atelier des rouesLab FR
Objects/Documentation

fibre09.py

I provide the computation for “Two origins in the same fibre give different windows”.

Download ↓
"""Exact origin-conditioned moments of a width-six unit count."""
from fractions import Fraction as F
from math import gcd
import json


def experiment():
    M=210
    counts=[sum(gcd((a+h)%M,M)==1 for h in range(6)) for a in range(M)]
    def stats(xs):
        mean=F(sum(xs),len(xs))
        return dict(mean=str(mean),variance=str(sum((x-mean)**2 for x in xs)/len(xs)),
                    empty=str(F(xs.count(0),len(xs))))
    global_stats=stats(counts)
    classes=[counts[i::6] for i in range(6)]
    mean=F(global_stats['mean'])

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.