Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
restrepo
GitHub Repository: restrepo/ComputationalMethods
Path: blob/master/homework/homework_2018_1_03_1035441007.ipynb
934 views
Kernel: Python 3
import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit from scipy import interpolate %pylab inline
Populating the interactive namespace from numpy and matplotlib
#Generamos los 3 puntos x=[1,3,9] y=[16,25,2]
#Graficamos los tres puntos plt.plot(x,y , ".k")
[<matplotlib.lines.Line2D at 0x7fbbfd527588>]
Image in a Jupyter notebook
#Usamos la función interp1d de Scipy que es de la forma scipy.interpolate.interp1d(x, y, kind=''), donde #x es el array con los datos de en x #y es el array con los datos de en y #Kind='' es un string ‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’ PolFit=interpolate.interp1d(x, y, kind='quadratic') #Graficamos el ajuste y los puntos y obtenemos la gráfica del ajuste. Xf=np.linspace(1,9,1000) Yf=PolFit(Xf) plt.plot(x, y, 'o', Xf, Yf, '-') plt.ylabel('Eje Y') plt.xlabel('Eje X') plt.title('PUNTOS Y AJUSTE CON POLINOMIO GRADO 2') plt.show()
Image in a Jupyter notebook
# ELABORADO POR NATALIA ALVAREZ CC 1.035.441.007