correlation

Generate correlated random numbers from binomial distributions in R

◇◆丶佛笑我妖孽 提交于 2019-11-26 14:11:55
问题 I am trying to find a way to generate correlated random numbers from several binomial distributions. I know how to do it with normal distributions (using mvrnorm), but I did not find a function applicable to binomial ones. 回答1: You can generate correlated uniforms using the copula package, then use the qbinom function to convert those to binomial variables. Here is one quick example: library(copula) tmp <- normalCopula( 0.75, dim=2 ) x <- rcopula(tmp, 1000) x2 <- cbind( qbinom(x[,1], 10, 0.5)

Calculate autocorrelation using FFT in Matlab

£可爱£侵袭症+ 提交于 2019-11-26 12:37:41
问题 I\'ve read some explanations of how autocorrelation can be more efficiently calculated using the fft of a signal, multiplying the real part by the complex conjugate (Fourier domain), then using the inverse fft, but I\'m having trouble realizing this in Matlab because at a detailed level. 回答1: Just like you stated, take the fft and multiply pointwise by its complex conjugate, then use the inverse fft (or in the case of cross-correlation of two signals: Corr(x,y) <=> FFT(x)FFT(y)* ) x = rand

use ggpairs to create this plot

一个人想着一个人 提交于 2019-11-26 11:03:14
问题 I have some code in a Shiny app that produces the first plot below. As you can see the font size varies with the size of the correlation coefficient. I would like to produce something similar with ggpairs (GGally) or ggplot2. The second image below was produced with the following code: library(GGally) ggpairs(df, upper = list(params = c(size = 10)), lower = list(continuous = \"smooth\", params = c(method = \"loess\", fill = \"blue\")) ) As you can see the size of the correlation font is

Use .corr to get the correlation between two columns

浪尽此生 提交于 2019-11-26 08:49:09
问题 I have the following pandas dataframe Top15 : I create a column that estimates the number of citable documents per person: Top15[\'PopEst\'] = Top15[\'Energy Supply\'] / Top15[\'Energy Supply per Capita\'] Top15[\'Citable docs per Capita\'] = Top15[\'Citable documents\'] / Top15[\'PopEst\'] I want to know the correlation between the number of citable documents per capita and the energy supply per capita. So I use the .corr() method (Pearson\'s correlation): data = Top15[[\'Citable docs per

Computing the correlation coefficient between two multi-dimensional arrays

巧了我就是萌 提交于 2019-11-26 00:48:33
问题 I have two arrays that have the shapes N X T and M X T . I\'d like to compute the correlation coefficient across T between every possible pair of rows n and m (from N and M , respectively). What\'s the fastest, most pythonic way to do this? (Looping over N and M would seem to me to be neither fast nor pythonic.) I\'m expecting the answer to involve numpy and/or scipy . Right now my arrays are numpy array s, but I\'m open to converting them to a different type. I\'m expecting my output to be

Computing the correlation coefficient between two multi-dimensional arrays

孤街醉人 提交于 2019-11-25 22:13:37
I have two arrays that have the shapes N X T and M X T . I'd like to compute the correlation coefficient across T between every possible pair of rows n and m (from N and M , respectively). What's the fastest, most pythonic way to do this? (Looping over N and M would seem to me to be neither fast nor pythonic.) I'm expecting the answer to involve numpy and/or scipy . Right now my arrays are numpy array s, but I'm open to converting them to a different type. I'm expecting my output to be an array with the shape N X M . N.B. When I say "correlation coefficient," I mean the Pearson product-moment