生成多维数据 [英] Generating multidimensional data

查看:75
本文介绍了生成多维数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

R是否具有用于在多维空间中生成随机数的程序包?例如,假设我要在长方体或球体内生成1000个点.

Does R have a package for generating random numbers in multi-dimensional space? For example, suppose I want to generate 1000 points inside a cuboid or a sphere.

推荐答案

也请检查copula软件包.这将在具有均匀边距但具有您设置的关联结构的多维数据集/超多维数据集中生成数据.然后可以将生成的变量转换为代表其他形状,但是仍然具有除独立之外的其他关系.

Also check out the copula package. This will generate data within a cube/hypercube with uniform margins, but with correlation structures that you set. The generated variables can then be transformed to represent other shapes, but still with relations other than independent.

如果您想要更复杂的形状,但对形状内的均匀性和独立性感到满意,则可以进行拒绝采样:在包含您的形状的多维数据集中生成数据,然后测试点是否在形状内,如果不存在,则拒绝它们否则,请继续这样做,直到有足够的分数为止.

If you want more complex shapes but are happy with uniform and idependent within the shape then you can just do rejection sampling: generate data within a cube that contains your shape, then test if the points are within your shape, reject them if not, then keep doing this until there are enough points.

这篇关于生成多维数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆