function [X, dX ] = RandomWalk( d, N, delta )
%% RANDOMWALK returns a d-dimensional random walk of N steps of *average* length
% delta following a normal distribution along all components;
% X(:,1) will contain the position at the end of the i-th step and
% dX(:,1) represents the current step
%
% *NOTE* the expectation of the L2 norm of X_final is
% E(|X|^2) = sqrt( d * sum( E( sum(X_i)^2 ) ) )
% = sqrt( d * N * amp^2 )
% = sqrt(N)*delta
%
% although the average vector X has expectation
% E(X) = zeros(d,1)
%
%
% copyright 2018 by Felix Fritzen (felix.fritzen@mechbau.uni-stuttgart.de)
% Institute of Applied Mechanics,
% University of Stuttgart, Germany
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see .
%
amp = delta / sqrt(d);
dX = randn( d, N ) * amp;
X = dX;
X = cumsum(dX, 2);