本文介绍了R-R中的多元正态分布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在R中模拟多元正态分布.我已经看到我需要mu和sigma的值.不幸的是,我不知道如何获得它们.

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.

在下面的链接中,您将在csv文件"Input.csv"中找到我的数据.谢谢 https://www.dropbox.com/sh/blnr3jvius8f3eh/AACOhqyzZGiDHAOPmyE__873? 0

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

请,你能给我举个例子吗?劳尔

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

推荐答案

您的链接已损坏,但我知道您希望根据经验多元正态分布生成随机样本.您可以这样操作,假设df是您的data.frame并包含数据:

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:

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

这篇关于R-R中的多元正态分布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 22:39