Python වැඩ්ඩො ඉන්නවද?
මචන් මට ඇකඩමිකල් වැඩකට ඕනි වෙලා තියෙන ඩේටා සෙට් එකකින් equation එකක් ගන්න. දන්න එකෙක් කියහන්කො කෝඩ් එක. Python බැරි නම් දන්න ඕනි එකක්.
පෝස්ට් එක අපැහැදිලි අයට
මගේ ලග ඩේටා සෙට් එකක් තියෙනවා , ඒකෙන් මට සමීකරනයක් ජෙනරේට් කරගන්න ඕන.
Data Set 1
3.878117483
3.752024414
3.535780834
3.205215931
3.024816319
2.627730805
2.42909089
2.200281917
1.959354628
1.875013261
1.567703677
1.447164504
Data Set 2
0.783998575
0.211088759
0.120622516
-0.325677765
-0.470417935
-0.82620818
-1.043270986
-1.260303847
-1.314556653
-1.736434965
-2.109942848
-2.711983467
Solved
# In[1]:
from numpy import *
# In[12]:
x = array([1,2,3,4,5,6,7,8,9,10,11,12])
y = array([0.783,0.211,0.120,-0.325,-0.470,-0.826,-1.043,-1.260,-1.314,-1.736,-2.109,-2.711])
# In[3]:
from scipy.interpolate import *
# In[15]:
p4 = polyfit(x,y,4) //fit our data(x,y) to a fourth degree polynomial
# In[16]:
print (p4)
# In[6]:
from matplotlib.pyplot import *
# In[7]:
%matplotlib inline
# In[17]:
plot(x,y,'o') //this is the plot of our data set
# In[18]:
plot(x,y,'o')
xp = linspace(0,12,1000) //devided the x line into 1000 parts for smooth p4 line by makeing an array
plot(xp,polyval(p4,xp),'b--') //plot p4 with xp, b=blue and --=dash line
මචන් මට ඇකඩමිකල් වැඩකට ඕනි වෙලා තියෙන ඩේටා සෙට් එකකින් equation එකක් ගන්න. දන්න එකෙක් කියහන්කො කෝඩ් එක. Python බැරි නම් දන්න ඕනි එකක්.
පෝස්ට් එක අපැහැදිලි අයට
මගේ ලග ඩේටා සෙට් එකක් තියෙනවා , ඒකෙන් මට සමීකරනයක් ජෙනරේට් කරගන්න ඕන.
Data Set 1
3.878117483
3.752024414
3.535780834
3.205215931
3.024816319
2.627730805
2.42909089
2.200281917
1.959354628
1.875013261
1.567703677
1.447164504
Data Set 2
0.783998575
0.211088759
0.120622516
-0.325677765
-0.470417935
-0.82620818
-1.043270986
-1.260303847
-1.314556653
-1.736434965
-2.109942848
-2.711983467
Solved
# In[1]:
from numpy import *
# In[12]:
x = array([1,2,3,4,5,6,7,8,9,10,11,12])
y = array([0.783,0.211,0.120,-0.325,-0.470,-0.826,-1.043,-1.260,-1.314,-1.736,-2.109,-2.711])
# In[3]:
from scipy.interpolate import *
# In[15]:
p4 = polyfit(x,y,4) //fit our data(x,y) to a fourth degree polynomial
# In[16]:
print (p4)
# In[6]:
from matplotlib.pyplot import *
# In[7]:
%matplotlib inline
# In[17]:
plot(x,y,'o') //this is the plot of our data set
# In[18]:
plot(x,y,'o')
xp = linspace(0,12,1000) //devided the x line into 1000 parts for smooth p4 line by makeing an array
plot(xp,polyval(p4,xp),'b--') //plot p4 with xp, b=blue and --=dash line
Last edited:

මොන ඩේට සෙට් එකද? මොන සමීකරණය ද?