从网格数据中随机采样:如何在 Matlab 中实现这一点?
我有一个 200x200 网格数据点。我想从该网格中随机选取 15 个网格点,并将这些网格中的值替换为从如下所示的已知分布中选择的值。所有 15
网格点都根据给定分布分配随机值。
给定的分布是:
Given Distribution
314.52
1232.8
559.93
1541.4
264.2
1170.5
500.97
551.83
842.16
357.3
751.34
583.64
782.54
537.28
210.58
805.27
402.29
872.77
507.83
1595.1
给定的分布由 20
值组成,这些值是网格数据点的一部分。这些20
网格点是固定的,即它们不能是随机选取15
点的一部分。这20个点的坐标是固定的,不应该是随机选取的一部分,它们是:
x 27 180 154 183 124 146 16 184 138 122 192 39 194 129 115 33 47 65 1 93
y 182 81 52 24 168 11 90 153 133 79 183 25 63 107 161 14 65 2 124 79
有人可以帮忙解决如何在Matlab中实现这个问题吗?
I have a 200x200
gridded data points. I want to randomly pick 15
grid points from that grid and replace the values in those grids with values selected from a known distribution shown below. All 15
grid points are assigned random values from the given distribution.
The given distribution is:
Given Distribution
314.52
1232.8
559.93
1541.4
264.2
1170.5
500.97
551.83
842.16
357.3
751.34
583.64
782.54
537.28
210.58
805.27
402.29
872.77
507.83
1595.1
The given distribution is made up from 20
values, which are part of those gridded data points. These 20
grid points are fixed i.e. they must not be part of randomly picking 15
points. The coordinates of these 20
points, which are fixed and should not be part of random picking, are:
x 27 180 154 183 124 146 16 184 138 122 192 39 194 129 115 33 47 65 1 93
y 182 81 52 24 168 11 90 153 133 79 183 25 63 107 161 14 65 2 124 79
Can someone help with how to implement this problem in Matlab?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基于 我对你的简单问题的回答,这是一个解决方案,说明如何选择 15 个随机整数点(即 200×200 矩阵中的下标索引)并分配从上面给出的值集中抽取的随机值:
在上面的代码中,我假设 x 坐标对应于 mat 中的行索引,y 坐标对应于列索引。如果实际上是相反的情况,请将第二个和第三个输入交换到函数 SUB2IND 。
Building off of my answer to your simpler question, here is a solution for how you can choose 15 random integer points (i.e. subscripted indices into your 200-by-200 matrix) and assign random values drawn from your set of values given above:
In the above code I'm assuming that the
x
coordinates correspond to row indices and they
coordinates correspond to column indices intomat
. If it's actually the other way around, swap the second and third inputs to the function SUB2IND.我认为尤达已经给出了基本的想法。调用 randi 两次以获取要替换的网格坐标,然后将其替换为适当的值。这样做 15 次。
I think yoda already gave the basic idea. Call randi twice to get the grid coordinate to replace, and then replace it with the appropriate value. Do that 15 times.