Permalink
Browse files

Implemented C theoretically, needs testing

  • Loading branch information...
1 parent 786fe9d commit fbd1cad6a3c9f872e93946e2fef09fd72a95686e @theoboyd committed Mar 9, 2012
Showing with 42 additions and 11 deletions.
  1. +42 −11 CWComplexityRun.m
View
@@ -67,31 +67,33 @@ function CWComplexityRun(simTime)
end
winSize = 20;
-windows = 1000/winSize;
+windows = simTime/winSize;
bucket = zeros(MODULES, windows); % Buckets for each module
% movAvgBucket = zeros(MODULES, 1);
-for window=1:(windows-1)
+for window=0:(windows-1)
for firing=1:length(firings1)
- start = window*winSize;
- t = firings1(firing,1);
- if ismember(t, start:(start + 20))
+ start = (window*winSize) + 1;
+ t = firings1(firing, 1);
+ if ismember(t, start:(start + winSize))
% Time is within the range of the window
neuron = firings1(firing,2);
- bucket(ceil(neuron/NpM), window) = bucket(ceil(neuron/NpM), window) + 1;
+ bucket(ceil(neuron/NpM), window + 1) = bucket(ceil(neuron/NpM), window + 1) + 1;
end
end
end
-differenced = aks_diff(bucket); % Difference once
+differenced = aks_diff(bucket'); % Difference once
differenced = aks_diff(differenced); % Difference twice
+C = zeros(TRIALS, numel(differenced))
+C(1)
for trial=1:TRIALS
- point = neuralComplexity(data)
+ C(trial) = neuralComplexity(differenced);
end
-plot(1:windows, bucket((module-1)*windows+1 : module*windows))
+plot(1:windows, differenced((module-1)*windows+1 : module*windows))
-f4 = figure
+f4 = figure;
clf
xlabel('Rewiting probability p')
xlim([0.1 0.5])
@@ -102,4 +104,33 @@ function CWComplexityRun(simTime)
holdoff
draw now
-saveas(f1, ['CWQuestion2.fig'], 'fig')
+saveas(f4, ['CWQuestion2.fig'], 'fig')
+
+end
+
+function sum = neuralComplexity(S)
+ sum = 0;
+ n = numel(S);
+ for i=1:n
+ sum = sum + MI(S(i), S) - I(S);
+ end
+end
+
+function output = MI(X, S)
+ output = H(X) + H(setdiff(S(:), [X])) - H(S);
+end
+
+function output = H(S)
+ n = numel(S);
+ abscovar = abs(cov(S));
+ logpart = log(2 * pi * exp(1)) .^n;
+ output = 0.5 * logpart * abscovar;
+end
+
+function sum = I(S)
+ sum = 0;
+ n = numel(S);
+ for i=1:n
+ sum = sum + H(S(i)) - H(S);
+ end
+end

0 comments on commit fbd1cad

Please sign in to comment.