Anda di halaman 1dari 4

6/8/2020 Untitled12 - Jupyter Notebook

TUGAS METODE NUMERIK REGRESI


NAMA : SITI EMA NURMAULIDA

NIM : G1B018057

1. Dari hasilpengukuran tegangan (V) dan arus (I) melalui sebuah resistor diperoleh data pada
tabel. Diketahui bahwa tegangan dan arus memiliki hubungan yaitu V = IR dengan R adalah
hambatan dari resistor. Dengan metode regresi linier, tentukan hambatan tersebut.

Jawab:

In [1]: 1 %matplotlib inline


2
3 # import modul-modul
4 import numpy as np
5 import matplotlib.pyplot as plt
6
7 # modul linier Algebra
8 import numpy.linalg as la
In [2]: 1 # data (V, I)
2 V = np.array ([1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5])
3 I = np.array ([0.57, 0.76, 1.09, 1.27, 1.54, 1.75, 2.05, 2.31, 2.58, 2.77])
4
5 # plot grafik data
6 plt.plot(V,I, 'ob');
7 plt.show()

localhost:8888/notebooks/Untitled12.ipynb# 1/4
In [3]: 1 # membuat matriks F
2 n = len(V)
3 F = np.column_stack([np.ones(n) ,V])
4
5 # menghitng matriks A = F^T . F
6 # B = F^T. I
7 A = F.T @ F
8 B = F.T @ I
9 print (A)
10 print (B)

[[ 10. 32.5 ]
[ 32.5 126.25]]
[16.69 64.54]
In [4]: 1 # solve M c = N
2 c = la.solve(A, B)
3 print(c)

[0.04636364 0.49927273]

In [6]: 1 x = np.linspace(0,6,10)
2 y = c[0] + c[1]*x
3 plt.plot(x,y,'-r')
4 plt.plot(V,I, 'ob');
5 plt.show()

2. Ilustrasi data pengukuran peluruhan bahan radioaktif (atau bisa juga dengan analogi
pengosongan kapasitor) diperoleh data pada tabel. Diketahui bahwa jumlah bahan/massa
radioaktif berubah terhadap waktu sesuai dengan N(t)=N0 exp(-λt). Dengan metode regresi,
tentukan nilai λ dari bahan tersebut.

jawab:
In [7]: 1 %matplotlib inline
2
3 # import modul-modul
4 import numpy as np
5 import matplotlib.pyplot as plt
6
7 # modul linier Algebra
8 import numpy.linalg as la

In [8]: 1 # data (t, N)


2 t = np.array ([0, 30, 60, 90, 120, 150, 180])
3 N = np.array ([1500, 752, 377, 189, 95, 48, 24])
4
5 # plot grafik data
6 plt.plot(t,N, 'ob');
7 plt.show()

In [9]: 1 # membuat matriks F


2 n = len(t)
3 F = np.column_stack([np.ones(n),t])
4
5 #menghitng matriks A = F^T . F
6 # B = F^T. N
7 A = F.T @ F
8 B = F.T @ N
9 print (A)
10 print (B)

[[7.00e+00 6.30e+02]
[6.30e+02 8.19e+04]]
[ 2985. 85110.]

In [10]: 1 # solve M c = N
2 c = la.solve(A, B)
3 print(c)

[1081.92857143 -7.28333333]
In [11]: 1 x = np.linspace(0,200,1500)
2 y = c[0] + c[1]*x
3 plt.plot(x,y,'-r')
4 plt.plot(t,N, 'ob');
5 plt.show()

In [12]: 1 # Nilai λ
2 # N(t) = N0 exp (-λt)
3 # λ ln 2 / 1/2 t / c[1]
4 λ = 0.693 / c[1]
5 print (λ)

-0.0951487414187643

3. Diberikan data berupa gambar dibawah ini. Gunakan program digitizer untuk mengubah data
gambar menjadi data numerik. Kemudian buatlah regresi nonlinier dengan fungsi
�(𝑥) = ��𝑥𝑝[−�(𝑥 − 𝑥0)2 ]
Jawab:

In [ ]: 1

Anda mungkin juga menyukai