Did I find the right examples for you? yes no      Crawl my project      Python Jobs

# cogent.maths.stats.test.correlation

All Samples(21)  |  Call(12)  |  Derive(0)  |  Import(9)

```from numpy import array, shape, fromstring, sqrt, zeros, pi
from cogent.core.usage import UnsafeCodonUsage as CodonUsage
from cogent.maths.stats.test import regress, correlation
from pylab import plot, cm, savefig, gca, gcf, arange, text, subplot, \
asarray, iterable, searchsorted, sort, diff, concatenate, silent_list, \
```
```        axes = gca()
m, b = regress(x, y)
r, significance = correlation(x,y)
#set the a, b, and r values. a is the slope, b is the intercept.
r_str = '%0.3g'% (r**2)
```

```from numpy import array, shape, fromstring, sqrt, zeros, pi
from cogent.core.usage import UnsafeCodonUsage as CodonUsage
from cogent.maths.stats.test import regress, correlation
from pylab import plot, cm, savefig, gca, gcf, arange, text, subplot, \
asarray, iterable, searchsorted, sort, diff, concatenate, silent_list, \
```
```        axes = gca()
m, b = regress(x, y)
r, significance = correlation(x,y)
#set the a, b, and r values. a is the slope, b is the intercept.
r_str = '%0.3g'% (r**2)
```

```import re
from cogent.util.transform import comb
from cogent.maths.stats.test import correlation
from operator import or_
from cogent.util.misc import InverseDict
```
```def distance_from_r_squared(m1, m2):
"""Estimates distance as 1-r^2: no correl = max distance"""
return 1 - (correlation(m1.flat, m2.flat)[0])**2

def distance_from_r(m1, m2):
"""Estimates distance as (1-r)/2: neg correl = max distance"""
return (1-correlation(m1.flat, m2.flat)[0])/2
```

```import re
from cogent.util.transform import comb
from cogent.maths.stats.test import correlation
from operator import or_
from cogent.util.misc import InverseDict
```
```def distance_from_r_squared(m1, m2):
"""Estimates distance as 1-r^2: no correl = max distance"""
return 1 - (correlation(m1.flat, m2.flat)[0])**2

def distance_from_r(m1, m2):
"""Estimates distance as (1-r)/2: neg correl = max distance"""
return (1-correlation(m1.flat, m2.flat)[0])/2
```

```from cogent.core.tree import TreeNode, PhyloNode, TreeError
from cogent.parse.tree import DndParser
from cogent.maths.stats.test import correlation
from cogent.util.unit_test import TestCase, main
from numpy import array, arange
```
```        m1 = array([[0,2,6.5],[2,0,6.5],[6.5,6.5,0]])
m2 = array([[0,2,6],[2,0,6],[6,6,0]])
r = correlation(m1.flat, m2.flat)[0]
self.assertEqual(obs, (1-r)/2)

```
```        m1 = array([[0,2,6.5],[2,0,6.5],[6.5,6.5,0]])
m2 = array([[0,2,6],[2,0,6],[6,6,0]])
r = correlation(m1.flat, m2.flat)[0]
self.assertEqual(obs, (1-r)/2)

```

```from cogent.core.tree import TreeNode, PhyloNode, TreeError
from cogent.parse.tree import DndParser
from cogent.maths.stats.test import correlation
from cogent.util.unit_test import TestCase, main
from numpy import array, arange
```
```        m1 = array([[0,2,6.5],[2,0,6.5],[6.5,6.5,0]])
m2 = array([[0,2,6],[2,0,6],[6,6,0]])
r = correlation(m1.flat, m2.flat)[0]
self.assertEqual(obs, (1-r)/2)

```
```        m1 = array([[0,2,6.5],[2,0,6.5],[6.5,6.5,0]])
m2 = array([[0,2,6],[2,0,6],[6,6,0]])
r = correlation(m1.flat, m2.flat)[0]
self.assertEqual(obs, (1-r)/2)

```

```from numpy import  array,ravel,around,ceil
from copy import copy
from cogent.maths.stats.test import correlation,spearman,correlation_test
from cogent.maths.stats.distribution import tprob,t_high
from biom.table import table_factory,DenseOTUTable
```
```
pearson_r,pearson_t_prob =\
correlation(flat_obs_data,flat_exp_data)

correlations["pearson"] = (pearson_r,pearson_t_prob)
```
```    #Now we get r by performing Pearson correlation
#on the rank data.
r, pearson_prob = correlation(x_ranks, y_ranks)

#However, the conversion to ranks affects the prob
```

```from cogent.parse.pdb import PDBParser
from cogent.struct.selection import einput
from cogent.maths.stats.test import correlation

```

```from cogent.parse.pdb import PDBParser