Professional Documents
Culture Documents
Plotting a graph between the voltage and distance and getting a relation which gives voltage at a given distance
Plotting a graph between the voltage and distance and getting a relation which gives voltage at a given distance
#y=beta_not+(beta_one)(x)
#Y=(a)((x)^(b))
#log(Y)=log(a)+((b)(log(x)))
#Plotting a graph between the voltage and distance and getting a relation which gives voltage at a given
distance
'''Values: '''
import matplotlib.pyplot as plt
import math
x =[]
y = []
for k in range(n):
p = math.log(a)
x.append(p)
q = math.log(b)
y.append(q)
x_bar=sum(x)/n
y_bar=sum(y)/n
bet1n=bet1d=0
for i in range(n):
for u in range(n):
be1n=(x[u])*((y[u])-y_bar)
bet1n+=be1n
for v in range(n):
be1d=(x[v])*((x[v])-x_bar)
bet1d+=be1d
beta1=bet1n/bet1d
beta0=y_bar-beta1*x_bar
plt.plot(x, y)
plt.xlabel('Distances(in cm)')
plt.ylabel('Voltage(in V)')
plt.show()
y_required=beta0+(beta1*x_given)
print("The Voltage at the given distance i.e.,",x_given,"is",y_required)
Output: