Need advice on my code for probability simulation
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am attempting to simulate this model below and output a transition matrix at the end.
I am having trouble with the last part of the code (see comment % help and % end help) where I am trying to list all possible outcomes and their probabilites (BB is the probability of buy buy, etc.) and output a transition matrix.
I have attempted this manually which is ok for a simulation of this size but if I wanted a larger simulation is there any way I can code this section instead of typing it all out manually?
A = [0 1
0 0]; % sets A equal to adjacency matrix of network of agents
j = [1
1] % sets j equal to pre-set states of agents in network
AgentStates = repmat( { 'Buy' }, numel( j ), 1 );
AgentStates( j == -1 ) = { 'Sell' } % lists agent states
A1 = j(1,1);
A2 = j(2,1);
K = 0.85; % sets value of constant 'k'
J = 0.8; % sets value of constant 'j'
S = sum(j) % sets the sum of states in network
p = (-K*S)/J % sets p equal to the value E must be greater than or less than in probablity distribution
PD = makedist('Normal','mu',0,'sigma',1); % normal distribution with mean '0' and variance '1'
PB = 1-cdf(PD,p) % finds the probability of a buy state using normal distribution
PS = cdf(PD,p) % finds probability of sell state using normal distribution
BB = PB*PB; % NEED HELP
BS = PB*PS;
SB = PS*PB;
SS = PS*PS;
T = [BB*BB BB*BS BB*SB BB*SS
BS*BB BS*BS BS*SB BS*SS
SB*BB SB*BS SB*SB SB*SS
SS*BB SS*BS SS*SB SS*SS] % END HELP
G = digraph(A);
P = plot(G); % plots graph 'G'
title('Network of Agents'); % sets title of graph
1 Kommentar
James Tursa
am 9 Nov. 2016
"... if I wanted a larger simulation ..."
In what way would it be larger? I.e., which additional variables would you have and how would T be built differently?
Antworten (1)
Devraj Dutt
am 9 Nov. 2016
Have you tried transprob (https://www.mathworks.com/help/finance/estimation-of-transition-probabilities.html).
0 Kommentare
Siehe auch
Kategorien
Mehr zu ThingSpeak finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!