Professional Documents
Culture Documents
datos = np.loadtxt("datos.txt")
x = datos[:, 0]
y = datos[:, 1]
yerr= datos[:, 2]
plt.title('Datos', fontsize=25)
plt.xlabel('Eje $x$')
plt.ylabel('Eje $y$')
plt.show()
In [4]:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
import numpy as np
datos = np.loadtxt("datos.txt")
x = datos[:, 0]
y = datos[:, 1]
sigma = datos[:,2]
a = np.arange(7, 8, 0.02, dtype =float)
b = np.arange(0.5, 1.2 , 0.013, dtype =float)
agrid, bgrid = np.meshgrid(a, b)
χ_cuadrado = sum((y - (agrid + bgrid*(x) ))**2 / (sigma)**2)
χ_cuadrado
In [5]:
minimo = np.argmin(χ_cuadrado)
a_val = a[minimo]
b_val = b[minimo]
a_val, b_val
In [7]:
np.min(χ_cuadrado)
Out[7]: 12.032409830788836
In [3]:
M=(np.column_stack((np.ones(np.size(x)),x)))
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
M
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
[1. , 7.153],
[1. , 8.402],
[1. , 1.133],
[1. , 6.124],
[1. , 2.214],
[1. , 0.397],
[1. , 2.807],
[1. , 2.937]])
In [226…
M.shape
Out[226… (50, 2)
In [4]:
Y = np.reshape(y, (50,1))
Y
Out[4]: array([[12.482],
[14.695],
[16.623],
[ 8.363],
[12.628],
[11.689],
[12.267],
[12.121],
[11.938],
[15.822],
[15.306],
[16.387],
[14.828],
[11.961],
[15.335],
[16.554],
[13.094],
[ 9.367],
[11.808],
[15.459],
[ 6.391],
[16.184],
[13.805],
[10.529],
[10.229],
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
[14.818],
[14.463],
[ 9.213],
[11.929],
[10.286],
[14.031],
[13.057],
[10.62 ],
[15.505],
[12.036],
[13.076],
[12.798],
[16.414],
[ 7.095],
[14.435],
[11.511],
[12.243],
[13.396],
[13.422],
[ 8.693],
[12.123],
[ 7.83 ],
[ 7.333],
[10.373],
[10.664]])
In [3]:
C = (sigma**2) * np.eye(50)
C
In [6]:
#Solución de máxima probabilidad
Θ = (np.linalg.inv(np.mat(np.transpose(M))*np.mat(np.linalg.inv(C))*np.mat(M)))*((
np.mat(np.transpose(M))*np.mat(np.linalg.inv(C))*np.mat(Y)))
Θ
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Out[6]: matrix([[7.59867088],
[0.89430915]])
In [7]:
#Matriz de covarianza
ΣΘ = (np.linalg.inv(np.mat(np.transpose(M))*np.mat(np.linalg.inv(C))*np.mat(M)))
ΣΘ
In [8]:
#incerteza para parámetros a y b:
a_inc=np.sqrt(ΣΘ[0,0])
b_inc=np.sqrt(ΣΘ[1,1])
a_inc, b_inc
In [6]:
from matplotlib import pyplot as plt
import numpy as np
datos = np.loadtxt("datos.txt")
x = datos[:, 0]
y = datos[:, 1]
x1 = np.sort(x)
plt.scatter(x, y, color='royalblue')
plt.title('Datos', fontsize=25)
plt.xlabel('Eje $x$')
plt.ylabel('Eje $y$')
plt.show()
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
In [ ]:
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD