如何在 VB 中使用库 Math.Net 的 Integrate.OnClosedInterval?
how to use Integrate.OnClosedInterval of the library Math.Net in VB?
I read the documentation of Mathdotnet but is unintelligible。
我根本不明白如何使用它。我想整合伽马分布的密度函数以获得条件期望。
I found this exemple in C# but it does not work in VB.
为了与上面的例子进行比较,我想做这样的事情:
MathNet.Numerics.Integrate.OnClosedInterval(x >= Gamma.PDF(alpha, beta, x), 0, p / 100)
VB 中的等价物是什么?
如果我回答你的问题是正确的,那么我会建议你的代码中应该有 lambda 表达式符号 (=>
)(我试图编辑它但被拒绝了)
- 需要导入
MathNet.Numerics
和 MathNet.Numerics.Distributions
命名空间。为此,您必须下载它。
- Lambda 表达式作为
OnClosedInterval()
的第一个参数,因此您必须像 vb.net 中的 Function(a)
你的vb.net代码可以这样,
Imports System
Imports MathNet.Numerics
Imports MathNet.Numerics.Distributions
Public Module Module1
Public Sub Main()
Console.WriteLine(Integrate.OnClosedInterval(Function(a) Gamma.PDF(alpha, beta, a), 0, p/100))
End Sub
End Module
你可以看例子here
I read the documentation of Mathdotnet but is unintelligible。 我根本不明白如何使用它。我想整合伽马分布的密度函数以获得条件期望。
I found this exemple in C# but it does not work in VB. 为了与上面的例子进行比较,我想做这样的事情:
MathNet.Numerics.Integrate.OnClosedInterval(x >= Gamma.PDF(alpha, beta, x), 0, p / 100)
VB 中的等价物是什么?
如果我回答你的问题是正确的,那么我会建议你的代码中应该有 lambda 表达式符号 (=>
)(我试图编辑它但被拒绝了)
- 需要导入
MathNet.Numerics
和MathNet.Numerics.Distributions
命名空间。为此,您必须下载它。 - Lambda 表达式作为
OnClosedInterval()
的第一个参数,因此您必须像 vb.net 中的
Function(a)
你的vb.net代码可以这样,
Imports System
Imports MathNet.Numerics
Imports MathNet.Numerics.Distributions
Public Module Module1
Public Sub Main()
Console.WriteLine(Integrate.OnClosedInterval(Function(a) Gamma.PDF(alpha, beta, a), 0, p/100))
End Sub
End Module
你可以看例子here