annotate distr_2.py @ 45:7d4da4e72d37

fix argv handling
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Tue, 05 Jul 2022 10:22:50 +0100
parents bb46148fab91
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
1 # experimenting with distributions
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
2 # Usage: distr.py N bucketWidth max
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
3 import sys, random, signif
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
4 from nltk import FreqDist
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
5
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
6 mu=float(sys.argv[1])
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
7 sigma=float(sys.argv[2])
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
8 n=int(sys.argv[3])
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
9 scale=float(sys.argv[4])
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
10 fd=FreqDist()
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
11 fd2=FreqDist()
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
12 for i in xrange(n):
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
13 fd[round(random.normalvariate(mu,sigma)/scale)]+=1
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
14 fd2[round(random.gauss(mu,sigma)/scale)]+=1
bb46148fab91 second half of old /c/Drive_F/merged_d/src/python/distr.py, modified to do coin flip experiment
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
15 fd.bell(xtra=fd2)