Need advice on my code for probability simulation

조회 수: 4 (최근 30일)
MK96
MK96 2016년 11월 9일
답변: Devraj Dutt 2016년 11월 9일
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
James Tursa
James Tursa 2016년 11월 9일
"... 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?

댓글을 달려면 로그인하십시오.

답변 (1개)

Devraj Dutt
Devraj Dutt 2016년 11월 9일
Have you tried transprob (https://www.mathworks.com/help/finance/estimation-of-transition-probabilities.html).

카테고리

Help CenterFile Exchange에서 ThingSpeak에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by