Example #1
0
def md(mu=1019,sigma=209):
	phi = []
	for i in range(400,1600,50):
		phi.append(gaussian.pdf(i,mu,sigma))
	stddraw.setYscale(0,1.1*max(phi))
	stdstats.plotLines(phi)
	stddraw.show()
Example #2
0
def main():

    hurst_ex = float(sys.argv[1])
    scale = 2**(2 * hurst_ex)
    fill_brownian(array, i, i1, variance, scale)
    stddraw.setYscale(-1, 1)
    stddraw.setXscale(0, len(array))
    stddraw.setPenRadius(0.0)
    stdstats.plotLines(array)
    stddraw.show()
def main():
    sh = []
    ch = []
    x = -5
    while x < 5:
        sh.append(sinh(x))
        ch.append(cosh(x))
        x += 0.2
    y = max(max(sh), max(ch))
    print(sh)
    print(ch)
    print(y)
    stddraw.setYscale(-y, y)
    stdstats.plotPoints(sh)
    stdstats.plotLines(ch)
    stddraw.show()
Example #4
0
def main():
    n = int(sys.argv[1])
    p = float(sys.argv[2])
    trials = int(sys.argv[3])
    t = int(sys.argv[4])
    q = evaluate(n, p, trials)
    stdio.writeln(q)

    norm = exTimes(n, p, trials, t)
    phi = stdarray.create1D(n + 1, 0.0)
    stddev = math.sqrt(n) / 2.0
    for i in range(n + 1):
        phi[i] = gaussian.pdf(i, n / 2.0, stddev)

    stddraw.setCanvasSize(1000, 400)
    stddraw.setYscale(0, 1.1 * max(max(norm), max(phi)))
    stdstats.plotBars(norm)
    stdstats.plotLines(phi)
    stddraw.show()
Example #5
0
def main(argv):

    n = int(argv[1])
    t = int(argv[2])
    stddraw.createWindow()
    stddraw.setYscale(0, 0.2)

    freq = [0] * (n+1)
    for t in range(t):
        freq[binomial(n)] += 1

    norm = [0.0] * (n+1)
    for i in range(n+1):
        norm[i] = float(freq[i]) / float(t)
    stdstats.plotBars(norm)

    stddev = math.sqrt(n) / 2.0
    phi = [0.0] * (n+1)
    for i in range(n+1):
        phi[i] = gaussian.phi(i, n/2.0, stddev)

    stdstats.plotLines(phi)
    stddraw.show()
    stddraw.wait()
        end = i

year = year[begin:end]
volume = volume[begin:end]
price = price[begin:end]

t = 0
for i in range(len(volume)):
    volume[i] = eval(volume[i]) / 100000
    t += volume[i]
    if (i + 1) % bili == 0:
        hVolume.append(t / bili)
        t = 0

t = 0
for i in range(len(price)):
    price[i] = eval(price[i])
    t += price[i]
    if (i + 1) % bili == 0:
        hPrice.append(t / bili)
        t = 0

print(len(hVolume))

stddraw.setCanvasSize(1000, 500)
stddraw.setYscale(0, 1.1 * max(max(hVolume), max(hPrice)))
stdstats.plotLines(hVolume)
stddraw.setPenColor(stddraw.BLUE)
stdstats.plotLines(hPrice)
stddraw.show()
import stdstats
import stddraw

#a = [1,1,9,3,5,6,8,10]
a = [1]

print('mean:', stdstats.mean(a))
print('var:', stdstats.var(a))
print('stddev:', stdstats.stddev(a))
print('median:', stdstats.median(a))
stddraw.setYscale(min(a) - 2, max(a) + 2)
stdstats.plotPoints(a)
stdstats.plotLines(a)
stdstats.plotBars(a)
stddraw.show()
Example #8
0
# draw the results to standard draw. Also draw the predicted Gaussian
# distribution function, thereby allowing easy comparison of the
# experimental results to the theoretically predicted results.

n = int(sys.argv[1])
trials = int(sys.argv[2])

freq = stdarray.create1D(n + 1, 0)
for t in range(trials):
    heads = stdrandom.binomial(n, 0.5)
    freq[heads] += 1

norm = stdarray.create1D(n + 1, 0.0)
for i in range(n + 1):
    norm[i] = 1.0 * freq[i] / trials

phi = stdarray.create1D(n + 1, 0.0)
stddev = math.sqrt(n) / 2.0
for i in range(n + 1):
    phi[i] = gaussian.pdf(i, n / 2.0, stddev)

stddraw.setCanvasSize(1000, 400)
stddraw.setYscale(0, 1.1 * max(max(norm), max(phi)))
stdstats.plotBars(norm)
stdstats.plotLines(phi)
stddraw.show()

#-----------------------------------------------------------------------

# python bernoulli.py 20 100000
Example #9
0
    r = [0] * 13
    for i in range(n):
        t = twodice()
        r[t] += 1
    return r


def crapS(n):
    r = [0] * 13
    for i in range(n):
        t = SicheDice()
        r[t] += 1
    return r


def drawDice(a=[]):
    stddraw.setYscale(0, 1.1 * max(a))
    stdstats.plotBars(a)


n = 1000000
d = crap(n)
dS = crapS(n)
print(d)
print(dS)
print(((d[7] + d[11])) / sum(d))
print((d[2] + d[3] + d[12]) / sum(d))
drawDice(d)
stdstats.plotLines(dS)
stddraw.show()
Example #10
0
 def plot(self):
     #stddraw.setPenColor('GRAY')
     stdstats.plotPoints(self._l)
     stdstats.plotLines(self._l)
Example #11
0
# distribution function, thereby allowing easy comparison of the
# experimental results to the theoretically predicted results.

n = int(sys.argv[1])
trials = int(sys.argv[2])

freq = stdarray.create1D(n+1, 0)
for t in range(trials):
    heads = stdrandom.binomial(n, 0.5)
    freq[heads] += 1
    
norm = stdarray.create1D(n+1, 0.0)
for i in range(n+1):
    norm[i] = 1.0 * freq[i] / trials
    
phi = stdarray.create1D(n+1, 0.0)
stddev = math.sqrt(n)/2.0
for i in range(n+1):
    phi[i] = gaussian.pdf(i, n/2.0, stddev)
    
stddraw.setCanvasSize(1000, 400)
stddraw.setYscale(0, 1.1 * max(max(norm), max(phi)))
stdstats.plotBars(norm)
stdstats.plotLines(phi)
stddraw.show()

#-----------------------------------------------------------------------

# python bernoulli.py 20 100000