📄 form3.frm
字号:
VERSION 5.00
Begin VB.Form Form3
Caption = "高斯分布"
ClientHeight = 5550
ClientLeft = 60
ClientTop = 450
ClientWidth = 8010
LinkTopic = "Form3"
ScaleHeight = 5550
ScaleWidth = 8010
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text2
Height = 495
Left = 2640
TabIndex = 8
Text = "0"
Top = 4920
Width = 1215
End
Begin VB.TextBox Text1
Height = 495
Left = 2640
TabIndex = 7
Text = "0"
Top = 4200
Width = 1215
End
Begin VB.PictureBox Picture1
AutoRedraw = -1 'True
Height = 3975
Left = 600
ScaleHeight = 3915
ScaleWidth = 7155
TabIndex = 2
Top = 120
Width = 7215
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 495
Left = 5400
TabIndex = 1
Top = 4320
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "返回"
Height = 495
Left = 5400
TabIndex = 0
Top = 4920
Width = 1095
End
Begin VB.Label Label4
Caption = "variance"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1080
TabIndex = 6
Top = 4800
Width = 1215
End
Begin VB.Label Label3
Caption = "mean "
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1440
TabIndex = 5
Top = 4200
Width = 975
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "-200"
Height = 180
Left = 120
TabIndex = 4
Top = 3840
Width = 360
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "200"
Height = 180
Left = 240
TabIndex = 3
Top = 120
Width = 270
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i, j, mean, var, y(1 To 250), a As Double
Const PI = 3.1415926
Private Sub Command1_Click()
Picture1.Cls
Picture1.Scale (0, 250)-(250, -250)
Picture1.Line (0, 0)-(250, 0)
Picture1.Line (0, -200)-(250, -200)
Picture1.Line (0, 200)-(250, 200)
mean = Text1.Text
var = Text2.Text
Randomize
y(1) = Sqr(var) * Sqr(-2 * Log(Rnd(250)) / Log(10)) * Sin(2 * PI * Rnd(250)) + mean
Picture1.Circle (1, y(1)), 1, RGB(10, 10, 255)
For i = 2 To 250
y(i) = Sqr(var) * Sqr(-2 * Log(Rnd(250)) / Log(10)) * Sin(2 * PI * Rnd(250)) + mean
Picture1.Line (i - 1, y(i - 1))-(i, y(i)), RGB(0, 0, 255)
Picture1.Circle (i, y(i)), 1, RGB(10, 10, 255)
n = 0
k = 0
For j = 1 To i
n = n + y(j)
k = k + (y(j) * y(j) - mean * mean)
Next j
a = Abs(k / j)
a = Sqr(a)
If k < 0 Then a = -a
Picture1.PSet (i, n / i), RGB(255, 0, 0)
Picture1.PSet (i, a), RGB(0, 255, 0)
Next i
End Sub
Private Sub Command2_Click()
Form3.Visible = False
Form1.Visible = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -