-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathgitgoing.py
executable file
·64 lines (48 loc) · 1.54 KB
/
gitgoing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
import numpy as np
__all__ = ['mean_plus_one', 'std_plus_one', 'cv', 'is_neuron_component',
'NEURON_COMPONENTS']
NEURON_COMPONENTS = ('soma', 'axon', 'dendrite', 'synapse')
def mean_plus_one(x):
"""Calculate the mean_plus_one value, plus 1 of an input matrix
Parameters
----------
x : numpy.array
An n-dimensional numpy array
Returns
-------
mean_plus_one : float
The mean_plus_one value in the entire array
"""
return np.mean(x) + 1
def std_plus_one(x):
"""Calculate the standard deviation, plus 1 of an input matrix
Parameters
----------
x : numpy.array
An n-dimensional numpy array
Returns
-------
std_plus_one : float
The standard deviation of the entire array
"""
return np.std(x) + 1
def cv(x):
"""Calculate the coefficient of variation of an entire array
The coefficient of variation is the standard deviation divided by the
mean_plus_one. It is a measure of the overall dispersion, and is used to
compare features with different variances and means on the same scale.
For more reading: http://en.wikipedia.org/wiki/Coefficient_of_variation
Parameters
----------
x : numpy.array
An n-dimensional numpy array
Returns
-------
cv : float
The coefficient of variation of the entire array
"""
#return mean_plus_one(x)/std_plus_one(x)
return std_plus_one(x)/mean_plus_one(x)
def is_neuron_component(component):
return component in NEURON_COMPONENTS