Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
I have a n symbols and a conditional probability matrix, how do I generate an output sequence from this n symbols using their respective conditional probability?

Subject: I have a n symbols and a conditional probability matrix, how do I generate an output sequence from this n symbols using their respective conditional probability?

From: DEVANAND

Date: 8 Aug, 2012 09:38:14

Message: 1 of 5

Hi all,

I have a n symbols and a conditional probability matrix, how do I generate an output sequence from this n symbols using their respective conditional probability?

-Devanand T

Subject: I have a n symbols and a conditional probability matrix, how do I

From: Torsten

Date: 8 Aug, 2012 10:46:58

Message: 2 of 5

On 8 Aug., 11:38, "DEVANAND " <devanandiam...@gmail.com> wrote:
> Hi all,
>
> I have a n symbols and a conditional probability matrix, how do I generate an output sequence from this n symbols using their respective conditional probability?
>
> -Devanand T

You mean you have transition probabilities p_ki that symbol i appears
at position j of the ouput sequence given that symbol k appeared at
position (j-1) of the output sequence and you want to generate a
random output sequence ?

Best wishes
Torsten.

Subject: I have a n symbols and a conditional probability matrix, how do I

From: DEVANAND

Date: 13 Aug, 2012 05:37:06

Message: 3 of 5

Yes.

Torsten <Torsten.Hennig@umsicht.fraunhofer.de> wrote in message <8f6fe359-3648-4796-8f24-c99db7c1718d@m13g2000vbd.googlegroups.com>...
> On 8 Aug., 11:38, "DEVANAND " <devanandiam...@gmail.com> wrote:
> > Hi all,
> >
> > I have a n symbols and a conditional probability matrix, how do I generate an output sequence from this n symbols using their respective conditional probability?
> >
> > -Devanand T
>
> You mean you have transition probabilities p_ki that symbol i appears
> at position j of the ouput sequence given that symbol k appeared at
> position (j-1) of the output sequence and you want to generate a
> random output sequence ?
>
> Best wishes
> Torsten.

Subject: I have a n symbols and a conditional probability matrix, how do I

From: Bruno Luong

Date: 13 Aug, 2012 08:20:07

Message: 4 of 5

% Generate random transition matrix M
n = 4;
M = zeros(n,n+1);
M(:,end) = 1;
M(:,2:end-1) = sort(rand(n,n-1),2);
M = diff(M,1,2);

% Engine
n = length(M);
C = [zeros(n,1) cumsum(M,2)];
 % Make sure equal to 1, prevent pb due to numerical calculation error
C(:,end) = 1;

Sk = 1; % Select intial state, whatever in [1,2, ...n]
S = zeros(1,100); % 100 = length of the sequence to be generated
S(1) = Sk;
for k=2:length(S)
    [~, Sk] = histc(rand,C(Sk,:));
    S(k) = Sk;
end
disp(S)

% Bruno

Subject: I have a n symbols and a conditional probability matrix, how do I

From: DEVANAND

Date: 17 Aug, 2012 08:23:07

Message: 5 of 5

Thanks for the code. I will check it.

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <k0adbn$ikm$1@newscl01ah.mathworks.com>...
> % Generate random transition matrix M
> n = 4;
> M = zeros(n,n+1);
> M(:,end) = 1;
> M(:,2:end-1) = sort(rand(n,n-1),2);
> M = diff(M,1,2);
>
> % Engine
> n = length(M);
> C = [zeros(n,1) cumsum(M,2)];
> % Make sure equal to 1, prevent pb due to numerical calculation error
> C(:,end) = 1;
>
> Sk = 1; % Select intial state, whatever in [1,2, ...n]
> S = zeros(1,100); % 100 = length of the sequence to be generated
> S(1) = Sk;
> for k=2:length(S)
> [~, Sk] = histc(rand,C(Sk,:));
> S(k) = Sk;
> end
> disp(S)
>
> % Bruno

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us