I am trying to plot a graph that takes a range of xvalues stored in a list and a function 'y' that takes those values as one of its operand . 'y' values are also stored in another array for each of xvalues.
I am generating a range of xvalues through random function, that will be stored in a list . For each xvalue i am calculating log value and storing it in list z . Another function : -Ta*log(xvalues)
Finally i need to plot graph for xvlaues in list 'a' and function values in list 't'
*************** ******** plot.py *************** ************
*************** *************** *************** **************
I am generating a range of xvalues through random function, that will be stored in a list . For each xvalue i am calculating log value and storing it in list z . Another function : -Ta*log(xvalues)
Finally i need to plot graph for xvlaues in list 'a' and function values in list 't'
*************** ******** plot.py *************** ************
Code:
import matplotlib.pyplot as plt
import math
a=[0]*6
z=[0]*6
b=[0]*6
t=[0]*6
import random
for i in range(5):
x=random.random()
y=3*x
a[i]=y
z[i]=math.log(a[i])
i = 0
while i <=5:
if i==0:
i=i+1
continue
else:
b[i]=a[i]-a[i-1]
i=i+1
s=0
i=0
while i<=5:
s=s+b[i]
i=i+1
Ta = s/6
for i in range(5):
t[i]=(-Ta)*z[i]
plt.plot(a,t)
plt.show()
Comment