Program Statistika Dasar
Buatlah form
seperti berikut ini:
Isikan kode
program berikut ini pada jendela kode:
Option
Base 1
Private
Sub cmdhasil_Click()
Dim
datastat(100) As Double
Dim
stat() As Double
List1.Clear
For
i = 1 To 100
datastat(i) = Int(Rnd() * 100000) + 1
List1.AddItem datastat(i)
Next
stat()
= arraystat(datastat())
For
i = 1 To 4
lblstatistik(i
- 1).Caption = stat(i)
Next
End
Sub
Function
arraystat(dataArray() As Double) As Double()
Dim
sumber(4) As Double
jumlah
= 0
jmlhkuadrat
= 0
jmlhdata
= 0
datamin
= 999999
datamax
= -999999
For
i = LBound(dataArray) To UBound(dataArray)
jumlah
= jumlah + dataArray(i)
jmlhkuadrat
= jmlhkuadrat + dataArray(i) ^ 2
If
dataArray(i) > datamax Then datamax = dataArray(i)
If
dataArray(i) < datamin Then datamin = dataArray(i)
jmlhdata = jmlhdata + 1
Next
ratarata = jumlah / jmlhdata
stdDev = Sqr(jmlhkuadrat / jmlhdata - ratarata ^ 2)
sumber(1) = ratarata
sumber(2) = stdDev
sumber(3) = datamin
sumber(4)
= datamax
arraystat
= sumber
End
Function
Private
Sub Form_Load()
Randomize
End Sub
Program Penjumlahan Matriks
Buatlah form seperti berikut ini.
Option
Explicit
Dim
baris, kolom
Dim
A() As Integer
Dim
B() As Integer
Dim
C() As Integer
Sub
dimensiA()
baris = Left(TXTMATRIKS(0).Text, 1)
kolom = Right(TXTMATRIKS(0).Text, 1)
End
Sub
Sub
dimensiB()
baris = Left(TXTMATRIKS(1).Text, 1)
kolom = Right(TXTMATRIKS(1).Text, 1)
End
Sub
Sub InputmatrikA(ByVal baris As Integer, ByVal kolom As
Integer)
Dim i As Integer,
j As Integer
ReDim A(baris, kolom)
For i = 1 To baris
For j = 1 To kolom
A(i, j) = InputBox("
Masukan elemen ke (" & i & "," & j &
")", " Input Matriks A")
Next j
Next i
For i = 1 To baris
For j = 1 To kolom
List1(0).AddItem "elemen
(" & i & "," & j & ")" & " =
" & A(i, j)
Next j
Next
End
Sub
Sub InputmatrikB(ByVal baris As Integer, ByVal kolom As
Integer)
Dim i As
Integer, j As Integer
ReDim
B(baris, kolom)
For i = 1 To
baris
For j = 1 To kolom
B(i, j)
= InputBox(" Masukan elemen ke (" & i & "," & j
& ")", " Input Matriks B")
Next j
Next i
For i = 1 To baris
For j = 1 To kolom
List1(1).AddItem "elemen
(" & i & "," & j & ")" & " =
" & B(i, j)
Next j
Next
End
Sub
Private
Sub CMDINPUT_Click(Index As Integer)
Select Case Index
Case 0
Call dimensiA
Call
InputmatrikA(baris, kolom)
Case 1
Call dimensiB
Call InputmatrikB(baris, kolom)
End Select
End
Sub
Sub penjumlahan()
Dim i As
Integer
Dim j As
Integer
ReDim C(baris,
kolom)
For i = 1 To
baris
For j = 1 To kolom
C(i, j) = A(i, j) + B(i, j)
Next j
Next i
For i = 1 To baris
For j = 1 To kolom
List1(2).AddItem "elemen("
& i & ", " & j & ")" & " = "
& C(i, j)
Next j
Next
End
Sub
Private
Sub CMDPENJUMLAHAN_Click()
Call penjumlahan
End
Sub
TUGAS
1. Buatlah program untuk mencari standar
deviasi dari sekelompok data.
2. Buatlah program untuk mencari persamaan
regresi dan korelasi dari dua kelompok data.
3.
Buatlah
program perkalian matriks.
0 komentar:
Posting Komentar