Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F# 将本机类型上的操作转换为Math.NET Numerics_F#_Math.net_Mathnet Numerics - Fatal编程技术网

F# 将本机类型上的操作转换为Math.NET Numerics

F# 将本机类型上的操作转换为Math.NET Numerics,f#,math.net,mathnet-numerics,F#,Math.net,Mathnet Numerics,在我从使用原生F#类型转向使用类型的过程中,一个示例将非常有用 以下内容如何表示为对或类型的操作?我一直在使用下面的代码片段,尝试将所有容器表示为Math.NET类型,但不断出现各种错误 open MathNet.Numerics open MathNet.Numerics.LinearAlgebra open MathNet.Numerics.Random open MathNet.Numerics.Distributions open MathNet.Numerics.Statistics

在我从使用原生F#类型转向使用类型的过程中,一个示例将非常有用

以下内容如何表示为对或类型的操作?我一直在使用下面的代码片段,尝试将所有容器表示为Math.NET类型,但不断出现各种错误

open MathNet.Numerics
open MathNet.Numerics.LinearAlgebra
open MathNet.Numerics.Random
open MathNet.Numerics.Distributions
open MathNet.Numerics.Statistics

let Tsize = 10
let Tsamps = 5

let expLL (arr : float []) = 
    arr |> Array.average

let arrL = Array.init Tsamps ( 
              fun i -> 
                 [| 
                     for i in 1 .. Tsize do 
                        yield Exponential.Sample(1.)
                 |] |> expLL 
           )

此外,将
float[]
float[][]
转换为
DenseMatrix
的最快方法是什么?

我不认为您的示例有任何需要做的不同-Math.NET为线性代数提供了很好的功能,但这里并没有进行任何矩阵或向量计算,所以基本数组可以正常工作。如果你想把结果变成一个向量,我可能会这样写(稍作调整以避免太长的行):

至于将数据转换为矩阵,有一个
矩阵
功能:

let nested = [ [1.0; 2.0; 3.0]; [4.0; 5.0; 6.0] ]
let m = matrix nested

我不认为您的示例有任何需要做的不同之处-Math.NET为线性代数提供了很好的功能,但您并没有真正在这里进行任何矩阵或向量计算,因此基本数组工作正常。如果你想把结果变成一个向量,我可能会这样写(稍作调整以避免太长的行):

至于将数据转换为矩阵,有一个
矩阵
功能:

let nested = [ [1.0; 2.0; 3.0]; [4.0; 5.0; 6.0] ]
let m = matrix nested

这里的expLL函数很简单,但实际上这就是我的大部分线性代数可能的地方。因此,我需要它来接受矩阵对象。但我想我现在看到了,这里的expLL函数很简单,但实际上这就是我的大部分线性代数可能的位置。因此,我需要它来接受矩阵对象。但我想我现在看到了。