具有更多评估点的双变量数据的 Matlab ksdensity
Matlab ksdensity for bivariate data with more evaluation points
我是 运行 内核密度的 Matlab 代码,即 [f,xi] = ksdensity(x)
,其中 x
是两列双变量数据。结果输出 f
是密度向量,而 xi
是评估点的网格,维度为 30x30。请参阅此处的文档:Link.
我正在尝试增加从此代码获得的评估点数。文档中提到的选项 'NumPoints'
仅适用于单变量数据。是否有选项或方法可以将双变量数据评估点的网格点增加到 100x100?
您需要在文档中使用可选的第二个输入参数 pts
to specify the range and number of the output points in your grid. See this example。根据您的输入数据,您可以指定如下内容:
pts = [linspace(min(x(:,1)),max(x(:,1)),1000).' linspace(min(x(:,2)),max(x(:,2)),1000).'];
NumPoints
是 ksdensity()
中的 npoints
。例如,[f,xi] = ksdensity(x, 'npoints', 1000)
将 return xi 和 f 的 1000 个点。
我是 运行 内核密度的 Matlab 代码,即 [f,xi] = ksdensity(x)
,其中 x
是两列双变量数据。结果输出 f
是密度向量,而 xi
是评估点的网格,维度为 30x30。请参阅此处的文档:Link.
我正在尝试增加从此代码获得的评估点数。文档中提到的选项 'NumPoints'
仅适用于单变量数据。是否有选项或方法可以将双变量数据评估点的网格点增加到 100x100?
您需要在文档中使用可选的第二个输入参数 pts
to specify the range and number of the output points in your grid. See this example。根据您的输入数据,您可以指定如下内容:
pts = [linspace(min(x(:,1)),max(x(:,1)),1000).' linspace(min(x(:,2)),max(x(:,2)),1000).'];
NumPoints
是 ksdensity()
中的 npoints
。例如,[f,xi] = ksdensity(x, 'npoints', 1000)
将 return xi 和 f 的 1000 个点。