Mercurial > hg > python
annotate distr_2.py @ 43:f67f9ea191b7
from http://sourceforge.net/projects/pdf2xml/files/misc/vec2svg-2.py/download
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Thu, 24 Feb 2022 15:43:26 +0000 |
parents | bb46148fab91 |
children |
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) |