# HG changeset patch # User Henry S. Thompson # Date 1627491263 -3600 # Node ID 6c389c0f1b40be701310b38aa7fcd0df0ec5923f # Parent 0bbeb01a76813f268a5a7f3171c0cc5fb7022e58 first half of old /c/Drive_F/merged_d/src/python/distr.py diff -r 0bbeb01a7681 -r 6c389c0f1b40 distr_1.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distr_1.py Wed Jul 28 17:54:23 2021 +0100 @@ -0,0 +1,27 @@ +#!/usr/bin/python3 +'''Display a bell curve for a fake normal distribution''' +# experimenting with normal distributions of coin flips +# Usage: distr.py Nexprs Mflips [differentN] +# Requires python3.6 as of 2021-07-28 +import sys, random, signif +from nltk import FreqDist + +n=int(sys.argv[1]) +m=int(sys.argv[2]) +if len(sys.argv)>3: + nn=int(sys.argv[3]) +else: + nn=None +fd=FreqDist() +for i in range(n): + fd[sum(random.randint(0,1) for i in range(m))]+=1 + +if nn is not None: + fd2=FreqDist() + for i in range(nn): + fd2[sum(random.randint(0,1) for i in range(m))]+=1 + + fd.bell(xtra=fd2) +else: + fd.bell() +