Варианты заданий к лабораторной работе
q | m | n | x1 | x2 | x3 | x4 | x5 | x6 | x7 | |
1 | 3 | 3 | 5 | 0 | 1 | 2 | 1 | 1 | - | - |
2 | 2 | 3 | 7 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
3 | 2 | 5 | 7 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
4 | 3 | 2 | 5 | 1 | 1 | 1 | 1 | 1 | - | - |
5 | 2 | 4 | 7 | 1 | 1 | 1 | 0 | 0 | 1 | 1 |
6 | 3 | 3 | 5 | 0 | 0 | 0 | 1 | 1 | - | - |
7 | 3 | 3 | 6 | 0 | 1 | 2 | 1 | 2 | 0 | - |
8 | 3 | 4 | 6 | 1 | 1 | 1 | 2 | 2 | 2 | - |
9 | 3 | 5 | 6 | 1 | 1 | 1 | 0 | 0 | 2 | - |
10 | 2 | 3 | 7 | 1 | 0 | 1 | 0 | 1 | 0 | 1 |
11 | 2 | 6 | 7 | 1 | 0 | 1 | 0 | 1 | 0 | 1 |
12 | 2 | 2 | 7 | 0 | 1 | 0 | 1 | 0 | 2 | 0 |
13 | 3 | 3 | 5 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
14 | 2 | 2 | 6 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
15 | 3 | 4 | 5 | 1 | 2 | 1 | 0 | 1 | 2 | 2 |
Интерфейс программы
Введённые значения: q-2, M-4, N-7
X1-1, X2-1, X3-1, X4-1, X5-0, X6-0, X7-1
Листингпрограммы
Public m, n, q, r, xe As Integer
Private Sub Command2_Click()
End
End Sub
Private Sub ok_Click()
list.Clear
If tm.Text = "" Or tn.Text = "" Or tq.Text = "" Or tx(0).Text = "" Or tx(1).Text = "" Or tx(2).Text = "" Or tx(3).Text = "" Or tx(4).Text = "" Then
MsgBox ("Сначала введите все значения")
Exit Sub
Else
Call fun
End If
End Sub
Private Sub fun()
Dim reg, regt As String
Dim xi(6), yi(100000), p(2), p0, p1, p2 As Integer
Dim xe As Double
n = CInt(tn.Text)
m = CInt(tm.Text)
q = CInt(tq.Text)
For i = 0 To (n - 1)
reg = reg & CStr(tx(i).Text)
Next
mg = q ^ n - 1
list.AddItem ("M=q^n-1 = " & mg)
list.AddItem ("")
For i = 1 To mg
yi(i) = Right(reg, 1)
r = CInt(Mid(reg, m, 1)) + CInt(Right(reg, 1))
If r >= q Then
r = r - q
Else
End If
If r = 0 Then p0 = p0 + 1
If r = 1 Then p1 = p1 + 1
If r = 2 Then p2 = p2 + 1
regt = reg
reg = CStr(r) & Mid(regt, 1, (n - 1))
list.AddItem ("Генератор=" & reg)
list.AddItem ("Число=" & yi(i))
list.AddItem ("R=" & r)
Next
list.AddItem ("")
p(0) = p0 / mg
p(1) = p1 / mg
p(2) = p2 / mg
For w = 0 To q - 1
list.AddItem ("p" & w & "=" & p(w))
Next w
For j = 0 To q - 1
xe = xe + ((1 / q) - p(j)) ^ 2
Next
xe = (1 / q) * xe
list.AddItem ("")
list.AddItem ("Критерий Пирсона=" & Round(xe, 12))
Dim mx, dx, kr, k As Double
mx = 0
For j = 1 To mg
mx = mx + CInt(yi(j))
Next
mx = mx / mg
list.AddItem ("")
list.AddItem ("Математическое ожидание=" & mx)
For j = 1 To mg
dx = (CInt(yi(i)) - mx) ^ 2
Next
dx = dx / (n - 1)
list.AddItem ("")
list.AddItem ("Дисперсия=" & dx)
list.AddItem ("")
list.AddItem ("Среднеквадратичное отклонение=" & Sqr(dx))
list.AddItem ("")
For i = 1 To q
For j = 1 To (mg - i)
k = k + ((CInt(yi(j)) - mx) * (CInt(yi(j + i)) - mx))
Next
kr = k / (mg - i - 1)
list.AddItem ("Автокорреляционнаяф-ия (" & i & ")= " & Round(kr, 12))
Next
End Sub
Список используемой литературы
1. Ли И. Т., Лабораторный практикум. Имитационное моделирование экономических процессов, Душанбе 2008 год