Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

adaptive_mult.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. % [val] = adaptive_mult(val, hit, {'hit_frac', 0}, {'stableperf', 0.75}, ...
  2. % {'mx', 1}, {'mn', 0}, {'do_callback', 0})
  3. %
  4. % Implements multiplicative staircase adaptation of a variable.
  5. %
  6. % PARAMETERS:
  7. % -----------
  8. %
  9. % val The value to be adapted.
  10. %
  11. % hit Pass this as 1 if latest trial was in the positive adaptation
  12. % direction; passit as 0 if it was in the negative direction
  13. %
  14. % OPTIONAL PARAMETERS
  15. % -------------------
  16. %
  17. % hit_frac How much to add to the parameter when hit==1. Default value
  18. % is 0, meaning no adaptation whatsoever.
  19. %
  20. % stableperf The percentage of positive trials that would lead to no
  21. % movement on average. stableperf is used to calculate the
  22. % size of how much is substracted from the SPH when
  23. % hit==0. Default value is 75%. Performance below this will
  24. % (on average) lead to motion in the -hit_frac direction;
  25. % performance above this will lead to motion in the hit_frac
  26. % direction.
  27. %
  28. % mx Maximum bound on the value: value cannot go above this
  29. %
  30. % mn Minimum bound on the value: value cannot go below this
  31. %
  32. %
  33. %
  34. % RETURNS:
  35. % --------
  36. %
  37. % val return the updated, post-adaptation value.
  38. %
  39. %
  40. % EXAMPLE CALL:
  41. % -------------
  42. %
  43. % >> block_length = adaptive_step(block_length, hit, 'hit_frac', -0.1, 'stableperf', 0.75, 'mx, ...
  44. % 50, 'mn', 2)
  45. %
  46. % Will increase my_sph by 1 every time hit==1, and will decrease it
  47. % by 3 every time hit==0. my_sph will be bounded within 90 and 100.
  48. %
  49. function [val] = adaptive_mult(val, hit, varargin)
  50. inpd = @utils.inputordefault;
  51. hit_frac = inpd('hit_frac',0 ,varargin);
  52. stableperf = inpd('stableperf', 0.75, varargin);
  53. mx = inpd('mx', 1, varargin);
  54. mn = inpd('mn', 0, varargin);
  55. log_hit_step = log10(1 + hit_frac);
  56. log_miss_step = stableperf*log_hit_step/(1-stableperf);
  57. if hit==1,
  58. val = val * (10.^log_hit_step);
  59. elseif hit==0
  60. val = val / (10.^log_miss_step);
  61. end
  62. % if hit is nan don't adapt
  63. if val > mx
  64. val = mx;
  65. end
  66. if val < mn
  67. val = mn
  68. end