-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_rewardpaths2.m
More file actions
executable file
·28 lines (26 loc) · 892 Bytes
/
make_rewardpaths2.m
File metadata and controls
executable file
·28 lines (26 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function paths = make_rewardpaths2(n_trials, n_contexts, n_paths, lb, ub, sd_r)
%MAKE_REWARDPATHS Generates random walk with Gaussian steps within bounds
%lb and ub
%
% Parameters
% ----------
% n_trials : int > 0 : Number of trials
% n_paths : int > 0 : Number of paths
% lb : 0 < float < ub : lower bound
% ub : lb < float < 1 : upper bound
% sd_r: float > 0 : standard deviation of the Gaussian steps
%
% Returns
% -------
% [n_trials by n_paths] array of reward probabilities
%
% Abraham Nunes (Last updated Nov 24, 2017)
% =========================================================================
sdt = sqrt(1/n_trials);
paths = NaN(n_trials, n_contexts, n_paths);
paths(1, :, :) = rand(n_contexts, n_paths)*(ub-lb) + lb;
for i = 2:n_trials
temp = paths(i-1, :, :) + sd_r*sdt*randn(1, n_contexts, n_paths);
paths(i, :, :) = max(min(temp, ub), lb);
end
end