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_step.m 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. % [val] = adaptive_step(val, hit, {'hit_step', 0}, {'stableperf', 0.75}, ...
  2. % {'mx', 1}, {'mn', 0}, {'do_callback', 0})
  3. %
  4. % Implements 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_step 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_step direction;
  25. % performance above this will lead to motion in the hit_step
  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_step', -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_step(val, hit, varargin)
  50. inpd = @utils.inputordefault;
  51. hit_step = inpd('hit_step',0 ,varargin);
  52. stableperf = inpd('stableperf', 0.75, varargin);
  53. mx = inpd('mx', 1, varargin);
  54. mn = inpd('mn', 0, varargin);
  55. miss_step = stableperf*hit_step/(1-stableperf);
  56. if hit==1
  57. val = val + hit_step;
  58. elseif hit==0
  59. val = val - miss_step;
  60. else
  61. warning('hit must be either 0 or 1!');
  62. end;
  63. if val > mx
  64. val = mx;
  65. end
  66. if val < mn
  67. val = mn;
  68. end