p = sys.argv.index('-type')
        ptemp = sys.argv[p + 1]
        type = ptemp

    if '-Ntoss' in sys.argv:
        p = sys.argv.index('-Ntoss')
        Nt = int(sys.argv[p + 1])
        if Nt > 0:
            Ntoss = Nt
    if '-Nexp' in sys.argv:
        p = sys.argv.index('-Nexp')
        Ne = int(sys.argv[p + 1])
        if Ne > 0:
            Nexp = Ne
    if '-output' in sys.argv:
        p = sys.argv.index('-output')
        OutputFileName = sys.argv[p + 1]
        doOutputFile = True

    if doOutputFile:
        outfile = open(OutputFileName, 'w')
        for e in range(0, Nexp):
            for t in range(0, Ntoss):
                if type == "nb":
                    outfile.write(str(random_number.Category6f()) + " ")

                if type == "bi":
                    outfile.write(str(random_number.Category6()) + " ")
            outfile.write(" \n")
        outfile.close()
Example #2
0
#! /usr/bin/env python

from Random import Random
import numpy as np
import matplotlib.pyplot as plt

random_number = Random(77777777)
myx = []

for x in range(1, 10000):
    faces = random_number.Category6()
    myx.append(faces)

# create histogram of our data
plt.figure()
plt.hist(myx,
         6,
         density=True,
         facecolor='green',
         histtype="barstacked",
         alpha=0.75)

# plot formating options
plt.xlabel('Dice faces')
plt.ylabel('Probability', fontweight="bold", fontsize="17")
plt.title('Categorical Distribution', fontweight="bold", fontsize="17")
plt.grid(True, color='r')

# save and show figure
plt.savefig("Dice.png")
#plt.show()