R -多变量R的正态分布

时间:2023-02-09 19:35:52

I would like to simulate a multivariate normal distribution in R. I've seen I need the values of mu and sigma. Unfortunately, I don't know how obtain them.

我想要模拟r中的多变量正态分布我知道我需要的是和的值。不幸的是,我不知道如何获得它们。

In the following link you will find my data in a csv file "Input.csv". Thanks https://www.dropbox.com/sh/blnr3jvius8f3eh/AACOhqyzZGiDHAOPmyE__873a?dl=0

在下面的链接中,您将在csv文件中找到我的数据。由于https://www.dropbox.com/sh/blnr3jvius8f3eh/AACOhqyzZGiDHAOPmyE__873a?dl=0

Please, could you show me an example? Raúl

请给我举个例子好吗?劳尔

1 个解决方案

#1


4  

Your link is broken, but I understand that you want to generate random samples from empirical multivariate normal distribution. You can do it like that, assuming df is your data.frame with data:

你的联系被打破了,但是我知道你想从经验多变量正态分布中产生随机样本。你可以这样做,假设df是你的数据。

library('MASS')
Sigma <- var(df)
Means <- colMeans(df)
simulation <- mvrnorm(n = 1000, Means, Sigma)

#1


4  

Your link is broken, but I understand that you want to generate random samples from empirical multivariate normal distribution. You can do it like that, assuming df is your data.frame with data:

你的联系被打破了,但是我知道你想从经验多变量正态分布中产生随机样本。你可以这样做,假设df是你的数据。

library('MASS')
Sigma <- var(df)
Means <- colMeans(df)
simulation <- mvrnorm(n = 1000, Means, Sigma)