← All NMath Code Examples
Imports System
Imports System.Data
Imports System.Collections
Imports CenterSpace.NMath.Core
Namespace CenterSpace.NMath.Examples.VisualBasic
A .NET example in Visual Basic showing one-way analysis of variance (anova).
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
This call is required by the Windows Form Designer.
InitializeComponent()
Add any initialization after the InitializeComponent() call
Create the data to analyze. Class OneWayAnova will accept data in
several formats. The one below uses an array of DoubleVectors. Each
vector in the array contains the data for a group.
Dim Table(4) As DoubleVector
Table(0) = New DoubleVector("[24 15 21 27 33 23]")
Table(1) = New DoubleVector("[14 7 12 17 14 16]")
Table(2) = New DoubleVector("[11 9 7 13 12 18]")
Table(3) = New DoubleVector("[7 7 4 7 12 18]")
Table(4) = New DoubleVector("[19 24 19 15 10 20]")
Create the one-way ANOVA
Dim Owa As OneWayAnova = New OneWayAnova(Table)
The AnovaTable property is a DataFrame instance that contains
a traditional ANOVA table. Use the ToDataTable() method of
the DataFrame to create a ADO DataTable.
Dim DT As DataTable = Owa.AnovaTable.ToDataTable()
Set the grids DataSource property to the DataTable just created.
DataGrid1.DataSource = DT
End Sub
Form overrides dispose to clean up the component list.
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
Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
NOTE: The following procedure is required by the Windows Form Designer
It can be modified using the Windows Form Designer.
Do not modify it using the code editor.
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents Label1 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.DataGrid1 = New System.Windows.Forms.DataGrid()
Me.Label1 = New System.Windows.Forms.Label()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
DataGrid1
Me.DataGrid1.BackgroundColor = System.Drawing.Color.White
Me.DataGrid1.CaptionVisible = False
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(24, 56)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.PreferredColumnWidth = 110
Me.DataGrid1.ReadOnly = True
Me.DataGrid1.RowHeadersVisible = False
Me.DataGrid1.Size = New System.Drawing.Size(664, 80)
Me.DataGrid1.TabIndex = 0
Label1
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(200, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(304, 24)
Me.Label1.TabIndex = 1
Me.Label1.Text = "One Way Anova Example"
Form1
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(706, 160)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1, Me.DataGrid1})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Name = "Form1"
Me.Text = "One Way Anova Example"
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
End Class
End Namespace
← All NMath Code Examples