Vb.net 如何找到数据的算法平均值(最大值和最小值)

Vb.net 如何找到数据的算法平均值(最大值和最小值),vb.net,algorithm,math,range,max,Vb.net,Algorithm,Math,Range,Max,所以我的项目是分析一个图表。我想找到算法来找到最大和最小数据。我在每个图中得到了不同的max值。所以我想找到平均值或高频最大值 我一直在寻找最大数据量。这是我的密码 Private Function FindMaxDataTableValue(ByRef dt As DataTable) As Integer Dim currentValue As Integer, maxValue As Integer Dim dv As DataView = dt.DefaultView

所以我的项目是分析一个图表。我想找到算法来找到最大和最小数据。我在每个图中得到了不同的max值。所以我想找到平均值或高频最大值

我一直在寻找最大数据量。这是我的密码

Private Function FindMaxDataTableValue(ByRef dt As DataTable) As Integer
    Dim currentValue As Integer, maxValue As Integer
    Dim dv As DataView = dt.DefaultView
    For c As Integer = 0 To dt.Columns.Count - 1
        dv.Sort = dt.Columns(c).ColumnName + " DESC"
        currentValue = CInt(dv(0).Item(c))
        If currentValue > maxValue Then maxValue = currentValue
    Next
    Return maxValue
End Function
如果可以使用LINQ(.NET 3.5+),则只需使用
Max
(和
Min
Average
)函数即可:

Private Function FindMaxDataTableValue(ByVal dt As DataTable) As Integer
    ' Find the max value for each column
    Dim maximums = (
        From c In dt.Columns.Cast(Of DataColumn)()
        Select dt.AsEnumerable().Max(Function(x) x.Field(Of Integer)(c))
    ).ToList()
    ' Return the highest of the maximums
    Return maximums.Max()
End Function

您可以这样做:对于每个图形,检查每个值。如果下一个值更高,则将第一个值存储在变量中,然后将其替换为更低的值。在上下文中定义高频最大值please@AlexB. 如何使用高频最大值我的意思是什么是高频最大值?根据您的业务环境,它是如何定义的。@AlexB。高频最大值是例如,我的数据是正弦曲线图,所以有不同的峰值。。。。还有
Average