mercredi 16 décembre 2020

Double the Variance of each component in R

I am trying to see how my scatter plot changes when I "double the variance in each component." I know how to find the variance of my samples, but I am confused on how I double them.

library(MASS)
library(ggplot2)

x<-mvrnorm(n=100, mu=c(0,0),Sigma=diag(2)) # 100 samples from a 2D normal variable with identity covariance matrix
print(x)
colnames(x)<-c('x1','x2')
x<-data.frame(x)
ggplot(x,aes(x=x1,y=x2))+geom_point()

Normally I would take 2 variables, find the variance of each of them, calculate the covariance, and use that in the above equation, but I believe this method to be wrong.




Aucun commentaire:

Enregistrer un commentaire