-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeasure.java
executable file
·67 lines (53 loc) · 1.97 KB
/
Measure.java
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
65
66
67
//This class is for measuring nets. It stores firing behavior
//and uses a Pearson's measurement.
import java.io.*;
import java.util.*;
public class Measure {
private int size;
public int MeasureCo1 = (int) 20;
public int MeasureCo2 = (int) 170;
private int FireNodes[] [] ;
private static final int CYCLESREMEMBERED = 1000;
private int getSize() {return size;}
public void setMeasure1(int value) {MeasureCo1 = value%CYCLESREMEMBERED;}
public void setMeasure2(int value) {MeasureCo2 = value%CYCLESREMEMBERED;}
public Measure(int numNeurons) {
size = numNeurons;
FireNodes = new int[CYCLESREMEMBERED][getSize()];
}
public int CountFireNodes (int Cycle){
int Result = 0;
for ( int counter = 0; counter <getSize(); counter++ )
if (FireNodes[Cycle][counter] == 1)
Result++;
return Result;
}
public double Measure(){
double Correlation;
double Sxx =0;
double Syy =0;
double Sxy =0;
double MeanS;
double MeanY;
double Sx=0;
double Sy=0;
// if (!RecordingActivation) {
// System.out.print("Recording Activation Off\n");
// }
for ( int counter = 0; counter <getSize(); counter++ )
Sx += FireNodes[MeasureCo1][counter];
MeanS = Sx/getSize();
for ( int counter = 0; counter < getSize(); counter++ )
{ Sy += FireNodes[MeasureCo2][counter]; }
MeanY = Sy/getSize();
for ( int counter = 0; counter <getSize(); counter++ ) {
Sxx += (FireNodes[MeasureCo1][counter]- MeanS)*(FireNodes[MeasureCo1][counter]- MeanS);
Syy += (FireNodes[MeasureCo2][counter]- MeanY)*(FireNodes[MeasureCo2][counter]- MeanY);
Sxy += (FireNodes[MeasureCo1][counter]- MeanS)*(FireNodes[MeasureCo2][counter]- MeanY); }
Correlation = Sxy/(Math.sqrt (Sxx*Syy));
return Correlation;
}
public void setActiveState(int Step, int nodeNum, int value) {
FireNodes[Step%CYCLESREMEMBERED][nodeNum] = value;
}
}