ott_RW_RPE_curr.m 637 B

123456789101112131415161718192021
  1. function [LH, probSpike, V, mean_predictedSpikes, RPE] = ott_RW_RPE_curr(startValues, spikeCounts, rewards, timeLocked)
  2. % firing rate only correlates with current reward; no real learning happens
  3. slope = startValues(1);
  4. intercept = startValues(2);
  5. rateParam = exp(slope*rewards + intercept);
  6. rateParam(rateParam < 0) = 0.1;
  7. probSpike = poisspdf(spikeCounts, rateParam(timeLocked)); % mask rateParam to exclude trials where the animal didn't lick fast enough
  8. mean_predictedSpikes = rateParam(timeLocked);
  9. if any(isinf(log(probSpike)))
  10. LH = 1e9;
  11. else
  12. LH = -1 * sum(log(probSpike));
  13. end
  14. V = NaN;
  15. RPE = NaN;