⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.vb

📁 基于vb.net的最小二乘法多项式系数计算类. 很好用,比Excel还精确.
💻 VB
📖 第 1 页 / 共 2 页
字号:
Imports System.IO
Imports System.IO.Stream
Imports System.Collections
Imports System.Math



Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " C骴igo generado por el Dise馻dor de Windows Forms "

    Public Sub New()
        MyBase.New()

        'El Dise馻dor de Windows Forms requiere esta llamada.
        InitializeComponent()

        'Agregar cualquier inicializaci髇 despu閟 de la llamada a InitializeComponent()

    End Sub

    'Form reemplaza a Dispose para limpiar la lista de componentes.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Requerido por el Dise馻dor de Windows Forms
    Private components As System.ComponentModel.IContainer

    'NOTA: el Dise馻dor de Windows Forms requiere el siguiente procedimiento
    'Puede modificarse utilizando el Dise馻dor de Windows Forms. 
    'No lo modifique con el editor de c骴igo.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Button4 As System.Windows.Forms.Button
    Friend WithEvents Button5 As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button3 = New System.Windows.Forms.Button
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Button4 = New System.Windows.Forms.Button
        Me.Button5 = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(8, 104)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(152, 23)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Power regression y= aX^b"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(8, 136)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(184, 23)
        Me.Button2.TabIndex = 1
        Me.Button2.Text = "Exponential regression y=ae^(bx)"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(8, 176)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(224, 23)
        Me.Button3.TabIndex = 2
        Me.Button3.Text = "Polynomial regression Ao +A1x + A2x^2..."
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(256, 24)
        Me.TextBox1.Multiline = True
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.TextBox1.Size = New System.Drawing.Size(248, 200)
        Me.TextBox1.TabIndex = 3
        Me.TextBox1.Text = ""
        '
        'Button4
        '
        Me.Button4.Enabled = False
        Me.Button4.Location = New System.Drawing.Point(296, 264)
        Me.Button4.Name = "Button4"
        Me.Button4.TabIndex = 4
        Me.Button4.Text = "Get Y"
        '
        'Button5
        '
        Me.Button5.Enabled = False
        Me.Button5.Location = New System.Drawing.Point(384, 264)
        Me.Button5.Name = "Button5"
        Me.Button5.TabIndex = 5
        Me.Button5.Text = "Get X"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(336, 240)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(72, 16)
        Me.Label1.TabIndex = 7
        Me.Label1.Text = "Interpolation:"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(16, 56)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(192, 32)
        Me.Label2.TabIndex = 8
        Me.Label2.Text = "Click on Button and read data from file on .\bin folder of project"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(0, 8)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(240, 32)
        Me.Label3.TabIndex = 9
        Me.Label3.Text = "CALCULATE REGRESSIONS FOR LEAST SQUARES METHOD"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(536, 302)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.Button5)
        Me.Controls.Add(Me.Button4)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    'This program calculate Regressions for Least Squares Method
    'Use 5 buttons for calculate:
    '   Power regression y= aX^b
    '   Exponential regression y=ae^(bx)
    '   Polynomial regression Ao +A1x + A2x^2...
    '   Get Y by interpolation
    '   Get X by interpolation
    'Use 1 Multiline TextBox for results
    '
    '
    'Data input from file RegPowerData.txt, ReaExpData.txt and 
    'RegPolyData.txt from folder .\bin of project 
    '    RegPowerData.txt:
    '       6.9, 21.4
    '       12.9, 15.7
    '       19.8, 12.1
    '       26.7, 8.5 
    '       35.1, 5.2 
    '       fit  y=30.497587426 exp(-0.049203708x)
    '    ReaExpData.txt:
    '        28,2410
    '        30,3033
    '        33,3895
    '        35,4491
    '        38,5717
    '        fit: y=0.238801069 x^2.771866158
    '    RegPolyData.txt:
    '        20,54 
    '        30,90 
    '        40,138
    '        50,206
    '        60,292
    '        70,396
    '        fit to poly order 2:   y= 41.771428571 - 1.095714286x + 0.087857143x^2


    'For each regression exist a Class inherits from "Regression" Class: 
    'PowerRegression, ExpRegression,PolyRegression
    '
    '**************
    'Regression Class (base class for calculate Least Squares Regressions)
    '  properties: 
    '           xVex, yVec: input, output data points x, y
    '           NumData: number of points
    '           aMat: store coefficients of matrix for build "normal equations"
    '           bVec: store constants of matrix for build "normal equations" also store
    '                 coefficients of regression when Regr()is executed 
    '  methods:
    '           Regr() : Overridable method for calculate regression
    '           BuildMat() : build "normal equations"

    '******************
    'PowerRegression Class (inherits from Regression Class)
    ' y= aX^b 
    'Calculate Power regression   
    '   Methods: Regr(): Set each data point to natural logarithm and calculate regression
    '            EvaluateX() for get Y given X
    '            EvaluateY() for get X given Y
    '****************
    'ExpRegression Class (inherits from Regression Class)
    'y = a e^(bx) 
    'Calculate Exponential regression   
    '   Methods: Regr(): Set each data point y(i) to Natural Logarithm and calculate regression
    '   EvaluateX() for get Y given X
    '   EvaluateY() for get X given Y

    '****************
    'PolyRegression Class (inherits from Regression Class)
    'y = Ao +A1x + A2x^2... 
    ' Calculate polynomial regression
    ' Properties: DegreePoly: input dregree of polynomial
    '             ChiSquare: get Chi Square
    '             Getr2: get Coefficient of Determination
    '             StandardError: get Standard Error
    '
    'Methods: Regr()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -