number_of_pairs.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. % [n] = number_of_pairs(sh, p) Compute number of expected simultaneously-recorded pairs of "interesting" neurons
  2. %
  3. % Given a histogram of (# of sessions) versus (# of single-units recorded
  4. % per session), and given a probability of a neuron being an "interesting"
  5. % neuron (i.e., having a high enough firing rate, task-related
  6. % activity, etc), produces an estimate of number of pairs of interesting,
  7. % simultaneously recorded neurons.
  8. %
  9. % PARAMETERS:
  10. % -----------
  11. %
  12. % sh A vector. The ith element in this vector should contain the
  13. % number of sessions in which there were i single units recorded.
  14. %
  15. % p The probability that a recorded neuron is "interesting" (however
  16. % you want to define it).
  17. %
  18. % RETURNS:
  19. % --------
  20. %
  21. % n Expected number of simultaneously recorded "interesting" pairs
  22. %
  23. %
  24. %
  25. % EXAMPLE CALL:
  26. % -------------
  27. %
  28. % >> number_of_pairs([4 5 3], 0.3)
  29. %
  30. % 1.7460
  31. %
  32. % gives the number of expected interesting pairs if in 4 sessions you
  33. % recorded only one single unit (those produce no pairs, of course), in 5
  34. % sessions you recorded two single units, and in 3 sessions you recorded
  35. % three single units; and the probability of an "interesting" cell is 0.3.
  36. %
  37. % CDB 15-June-2012
  38. function [n] = number_of_pairs(sh, p)
  39. n=0;
  40. for i=2:numel(sh), % i is going to be the # of singles recorded
  41. for k=2:i % k is going to be the number of "interesting" neurons
  42. pk = nchoosek(i,k)*p.^k*(1-p).^(i-k); % probability of k "interesting" neurons in i recorded neurons, assuming independence
  43. ek = sh(i)*pk; % expected number of sessions in which we got k "interesting" neurons
  44. n = n + ek*nchoosek(k,2); % number of pairs we get out of k neurons (e.g., when k=3 that's three different pairs)
  45. end
  46. end;