-
Notifications
You must be signed in to change notification settings - Fork 0
/
modelandvisual.py
88 lines (67 loc) · 1.96 KB
/
modelandvisual.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#Leyton Taylor Lab 1
import random
import matplotlib.pyplot as plt
def genOrbits():
Fout=dict()
Gout=dict()
Dout=dict()
randomFseeds=[random.uniform(-1.99,1.99) for k in range(10)]
randomGseeds=[random.uniform(-1.99,1.99) for k in range(10)]
randomDseeds=[random.random() for k in range(10)]
Fout={x:F(x) for x in randomFseeds}
Gout={x:G(x) for x in randomGseeds}
Dout={x:D(x) for x in randomDseeds}
print("F seeds: "+str(randomFseeds)+'\n'
+"G seeds: "+str(randomGseeds)+'\n'
+"D seeds: "+str(randomDseeds))
return Fout,Gout,Dout
##x belongs to [0,1)
def F(x):
outList=[(0,x)]
temp=x
for i in range(1,100):
lastOut=temp**2-2
temp=lastOut
outList.append((i,temp))
return outList
##c<-2, -2<x<2
def G(x):
outList=[(0,x)]
temp =x
for i in range(1,100):
lastOut=temp**2-20
temp=lastOut
outList.append((i,temp))
return outList
##0<=x<1
def D(x):
outList=[(0,x)]
temp=x
for i in range(1,100):
if(temp<.5 and temp>=0):
lastOut=temp*2
temp=lastOut
outList.append((i,temp))
else:
lastOut=temp*2-1
temp=lastOut
outList.append((i,temp))
return outList
##Creates a plot of the orbit and seed
def plotLine(orbitDict,seed):
plt.ylabel='Output of Iteration'
xAxis=[orbitDict[seed][n][0] for n in range(100)]
yAxis=[orbitDict[seed][n][1] for n in range(100)]
plt.plot(xAxis,yAxis)
plt.show()
##Plots a visualization of the period
def plotPeriod(orbitDict,seed):
xAxis=[]
yAxis=[]
for k in orbitDict[seed]:
if(k[1]==seed):
yAxis.append(seed)
xAxis.append(k[0])
plt.plot(xAxis,yAxis, 'ro')
plt.axis([0,100,-2,2])
plt.show()