comparison distr_1.py @ 27:6c389c0f1b40

first half of old /c/Drive_F/merged_d/src/python/distr.py
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Wed, 28 Jul 2021 17:54:23 +0100
parents
children
comparison
equal deleted inserted replaced
25:0bbeb01a7681 27:6c389c0f1b40
1 #!/usr/bin/python3
2 '''Display a bell curve for a fake normal distribution'''
3 # experimenting with normal distributions of coin flips
4 # Usage: distr.py Nexprs Mflips [differentN]
5 # Requires python3.6 as of 2021-07-28
6 import sys, random, signif
7 from nltk import FreqDist
8
9 n=int(sys.argv[1])
10 m=int(sys.argv[2])
11 if len(sys.argv)>3:
12 nn=int(sys.argv[3])
13 else:
14 nn=None
15 fd=FreqDist()
16 for i in range(n):
17 fd[sum(random.randint(0,1) for i in range(m))]+=1
18
19 if nn is not None:
20 fd2=FreqDist()
21 for i in range(nn):
22 fd2[sum(random.randint(0,1) for i in range(m))]+=1
23
24 fd.bell(xtra=fd2)
25 else:
26 fd.bell()
27