Created
July 11, 2021 14:29
-
-
Save danilo-bc/9e429d31ac2c3ac4c13dfe87610c297e to your computer and use it in GitHub Desktop.
Calculate Stochastic Computing Correlation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from bitarray import bitarray | |
| # Currently unused in the project | |
| def SCC(X,Y): | |
| '''Calculated Stochastic Circuit Correlation between X and Y''' | |
| # overlapping 1's | |
| a = (X&Y).count() | |
| # overlapping 1's of X and 0's of Y | |
| b = (X&~Y).count() | |
| # overlapping 0's of X and 1's of Y | |
| c = ((~X)&Y).count() | |
| # overlapping 0's | |
| d = (~(X|Y)).count() | |
| if(a*d>b*c): | |
| return (a*d-b*c)/(len(X)*np.min([a+b,a+c])-(a+b)*(a+c)) | |
| else: | |
| return (a*d-b*c)/((a+b)*(a+c)-len(X)*np.max([a-d,0])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment