Third time job

Source: Internet
Author: User

5, given the probability model as shown in table 4-9, the real value label of the sequence A1A1A3A2A3A1 is obtained.

For:

obtained by test instructions: The real value label of the sequence A1A1A3A2A3A1 is the real value label of the sequence 113231.

Set upper bound U (0) = 1, Nether L (0) = 0, symbol set A={A1,A2,A3}, and P (A1) =0.2,p (A2) =0.3,p (A3) =0.5

Because P (x=i) =p (AI), so P (x=1) =p (a1) = 0.2,

P (x=2) = P (a2) = 0.3,

P (x=3) =p (A3) =0.5.

FX (0) =0, FX (1) =p (A0) + p (A1) =0.2, FX (2) =p (A1) + p (A2) =0.5, FX (3) =p (A1) + p (A2) +p (A3) =1

Again because U (k) =l (k-1) + (U (k-1)-L (k-1)) *fx (XK)

L (k) =l (k-1) + (U (k-1)-L (k-1)) *fx (xk-1)

So the results are as follows:

The first element of the sequence is 1

U (1) =l (0) + (U (0)-L (0)) *fx (1) =0+ (1-0) *0.2=0.2

L (1) =l (0) + (U (0)-L (0)) *fx (0) =0+ (1-0) *0=0

So the range of the label [0,0.2]

The second element of the sequence is 1

U (2) =l (1) + (U (1)-L (1)) *FX (1) =0+ (0.2-0) *0.2=0.04

L (2) =l (1) + (U (1)-L (1)) *fx (0) =0+ (0.2-0) *0=0

So sequence 1 1 label interval [0,0.04]

The third element of the sequence is 3

U (3) =l (2) + (U (2)-L (2)) *FX (3) =0+ (0.04-0) * * =0.04

L (3) =l (2) + (U (2)-L (2)) *fx (2) =0+ (0.04-0) *0.5=0.02

So the range of the sequence label [0.02,0.04)

The fourth element of the sequence is 2

U (4) =l (3) + (U (3)-L (3)) *fx (2) =0.02+ (0.04-0.02) *0.5 =0.03

L (4) =l (3) + (U (3)-L (3)) *fx (1) =0.02+ (0.04-0.02) *0.2=0.024

So sequence 2 3 label interval [0.024,0.03]

The fifth element of the sequence is 3

U (5) =l (4) + (U (4)-L (4)) *fx (3) =0.024+ (0.03-0.024) *1=0.03

L (5) =l (4) + (U (4)-L (4)) *fx (2) =0.024+ (0.03-0.024) *0.5=0.027

So the range of the sequence label [0.027,0.03)

The sixth element of the sequence is 1

U (6) =l (5) + (U (5)-L (5)) *fx (1) =0.027+ (0.03-0.027) *0.2=0.0276

L (6) =l (5) + (U (5)-L (5)) *fx (0) =0.027+ (0.03-0.027) *0=0.027

So the range of the sequence label [0.027,0.0276)

The real value tags for the A1A1A3A2A3A1 series are:

Tx (113231) = (U (6) + L (6))/2

= (0.0276+0.027)/2

=0.0546/2

=0.0273

6. For the probability model given in table 4-9, a sequence with a length of 10 labeled 0.63215699 is decoded.

Solution: The following procedures can be obtained according to test instructions:

#include <stdio.h>

int main ()
{
int m[20];
Double f0=0,f1=0.2,f2=0.5,f3=1.0;
Double tag=0.63215699,t1;
Double l[20],u[20];
l[0]=0;
u[0]=1.0;
for (int j=1;j<=10;j++)
{
T1= (Tag-l[j-1])/(u[j-1]-l[j-1]);
if (T1>F0&&T1<F1)
{
l[j]=l[j-1]+ (u[j-1]-l[j-1]) *f0;
u[j]=l[j-1]+ (u[j-1]-l[j-1]) *f1;
M[j]=1;
}
else if (T1>F1&&T1<F2)
{
l[j]=l[j-1]+ (u[j-1]-l[j-1]) *f1;
u[j]=l[j-1]+ (u[j-1]-l[j-1]) *f2;
m[j]=2;
}
Else
{
l[j]=l[j-1]+ (u[j-1]-l[j-1]) *f2;
u[j]=l[j-1]+ (u[j-1]-l[j-1]) *f3;
m[j]=3;
}
printf ("%d\n", M[j]);
}

return 0;

}

The result of debugging is 3221213223.

Third time job

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.