forked from nmtimme/Neuroscience-Information-Theory-Toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
statejit.m
36 lines (32 loc) · 928 Bytes
/
statejit.m
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
29
30
31
32
33
34
35
36
%% statejit - jitter states
% Jitters states with adjacent states in time order, trial order, or
% whatever order they are presented. The jittering is performed using a
% Gaussian distribution with a supplied standard deviation (in units of
% bins).
%
% Syntax: [randstates] = statejit(states,std)
%
% Input:
% states (vector double) -
% std (scalar) -
%
%
% Outputs:
% randstates (vector double) - randomized version of the input states
%
%
% Examples:
% Jitter with 2 bin standard deviation
% states = rand([100,1]);
% randstates = statejit(states,2);
%
% Other m-files required: none
% Subfunctions: none
% MAT-files required: none
%
% Author: Nick Timme
% Email: [email protected]
% August 2016; Last revision: 01-Aug-2016
function [randstates] = statejit(states,stdev)
[waste,I] = sort((1:length(states)) + stdev*randn([1,length(states)]));
randstates = states(I);