Welcome to the lecture on problem solving based on random number and random variate generation So, in the last lecture we have discussed about how to generate the random numbers and also the random variates of different types of distribution functions So, in this lecture we will try to solve some of the problems In the case of random number generation, we would like to solve the problems where we will find the random numbers based on congruential generators and we will also solve problems based on the uniformity and dependence taste for the random number generated So, the first question is that for a multiplicative generator We have to find Zi for enough values of i greater than equal to 1 to cover the entire cycle So, this is a case of multiplicative generator congruential generator Because you do not have the value of c the expression is a multiplied by Zi minus 1 plus c mod m So, the c is 0 That is why it is known as multiplicative conventional generator So, in this case we will see that how the period is varying for the different cases Because we see that we have two values of the seed that is 1 and 2 And we have the initial value a, a is also different differently taken and m is also differently taken So, this way we will try to see how to generate first of all the random numbers And then how to see that how the period is varying when we change these parameters So, let us solve the first problem The first problem is that we have a is Z naught is 1, a is 11, m is 16 So, question 1, now in this case we have i and Z i So, let us see the Z naught is 1 So, when i is 0, it is 1 The expression is expression will be Zi will be a into Zi minus 1 into mod m So, in this case you have a as 11, m is 16 So, 11 Zi minus 1 into mod 16 Now once we have i is 0, Z naught is given as 1 So, Z naught given is, Z naught as 1, a as 11 and m as 16 Now, So, once we go further we can just go and get the values So, if it is 1, it will be 11 Then i will be 2 So, once i is 2, Z 2 will be 11 into 11 So, 121 mod 16 So, 16 into 7 plus 9 So, it will be 9 Go to 3, 9 into 11, 99 mod 16 So, 6 into 16 plus 3 So, it will be 3 4 3 into 11 33 mod 16 So, it will be 1 5, 1 into 11 mod 16 So, it is 11 So, what we see is this 11 has come here

It means the period is only four 11, 9, 3, 1 And then 11 has come So, what we see is that the period is you know 16 by 4 So, we had seen that in one case the maximum period is 2 raised to the power b So, b is anyway here 4 and in some case it will be 2 raised to the power b minus 2 So, in this case we are seeing that this model, I mean period is 4 So, this will go on repeat So, what we see is that in this case period is 4, that is m by 4 because it m is 16 So, 16 by 4 it is 4 So, this is the a part Let us go to the b part In case of b it will be Zi will be a into Zi minus 1 So, a is 11 and then here the mod is 16 and Z 0 is given as 2 So, in this case you will go like this You have i and you have Z i So, once i is 0 it is 2 Now how it will move So, in the first case what will be there So, in the first case 2 into 11 So, it is 22 mod 16 So, it will be 6 Z 2, for Z 2 this 6 has come So, 11 into 6, 66 mod 16 So, it will be 2 it means further it will go to 6 and so on So, here we see that only the period is 2, you are getting only 2 random numbers And after that the series is recycling or cycling So, this you are cycling you see only after 2 entries So, m is 2 Next question, c part In c you have Z naught as 1 and a has 2, m as 13 Now, in this case what will happen? You have i and Z i So, Z naught is given as 1 So, if it is 0, it is 1 So, c part Z naught as 1 in this case the expression will be Zi will be a into Zi minus 1 So, 2 into Zi minus 1 and then mod 13 So, once the first value is 1, when i is 1 in that case 2 times 1 So, it will be 2 in the second case 2 into 2, 4 mod 13 so, 4 3, 4 into 2, 8 mod 13 so, 8 4, 8 into 2, 16 mod 13 so, 3 16 mod 13 will be 3 where 13 into 1 plus 3, so, it will be 3 5 is 6 6 will be 12 7 will be 12 into 2, 24, so, it will be 11 8 will be 11 into 2, 22 so, it will be 9

9 will be 9 into 2, 18 so, 5 10, 10 will be 5 into 2, 10 11 will be 10 into 2 mod 13, 7 12, 7 into 2, 14 mod 13 so, it will be 1 So, it will be further going towards to end all that So, what we see is that you have the period going from 1 to 12 and then it is repeating So, what we see is in this case period is 12 that is m minus 1 So, in this case we see that the maximum period is achieved So, that is 12 equal to m minus 1 We take the last part d part of the question number 1 in question number d, 1d, Z 0 is 2, a is 3 and m is 13 So, so Zi will be a is 3 So, 3 Zi minus 1 mod 13 So, again in this case i and Zi at 0 it is 2 So, then with 1 It will be 2 times 3, 6 mod 13 So, it will be 6 then 6 into 3, 18 mod 13 So, then you have 2, 6 into 3, 18 mod 13 So, it will be 5 In third case 5 into 3, 15 mod 13, it will be 2 So, further it will be going In this case what we see is that you have 6, 5, 2 mod So, the 3 random members you are getting in after that it is getting repeated So, here the period is 3 This is how you calculate the periods of the generator, which have different values of the seed, multipliers and the increment as well as the modulus modular values We will go to next question Question number 2 Question number 2 is that you have to generate 3 random variables in 0 one using the seed value as 27 X naught, a is 8, c 47 and m is 10 raise to the power 2 So, the concept is that you are going to use the linear congruential generators formula That is Xi will be a into Xi minus 1 plus c mod m So, in that basis expression will be Xi will be a, a is your value here 8 So, 8 into Xi minus 1 plus c, c is 47 And then you have mod 10 raise to the power 2 So, again here also we can generate the numbers i and Xi and X naught or X 0 is given as 27 So, when i is 0, it is 27 When i will be 1 in that case 8 into 27, 216 plus 47 So, that is 263 mod 100 So, last 2 digits will be taken So, it will be 63 Now, in this case you have to generate the variates So, in the in finding the variates, you are going to divide it by m Because the maximum number is m you are getting the model mod of m So, you are going to divide it by m that is 10 raise to the power 2 So, your number will come as 0.63

Similarly, 2 So, again 63 into 8, 504 plus 47 So, 551 So, 551 has and then further mod of that as 100 So, it will be 51 So, the variate will be 0.51 Then in the third case the third number will be 51 into 8, 408 plus 47 So, that will be 455 So, 455 divided and mod of that with 100 So, that will give you 55 So, you will get the variate as 0.55 and this way you can go So, what you see that 3 variates in 0 to 1 are answer is 0.63, 0.51 and 0.55 this is the answer So, whenever we have to generate the variate in certain domain in that case in between 0 to 1 in that case the number, which you are getting using the linear congruential generator or any generator In that case and you do the modulo operation in that case you are going to divide it by the mod value And then you are getting then the variates in between 0 and 1 So, this is how it is solved The next question is regarding the finding of uniformity, whether the number which is sequence in certain sequence, whether it is uniform or not and you are given certain value of alpha That is 0.05 to check the uniformity test with the form with that test method of Kolmogorov Simonov test So, for that we will try to have the data And we will see we have seen how to do it So, in that question 2 We have the data as 0.68 So, the data is 0.54, 0.73, 0.98, 0.11 and 0.68 Now in that case So, you have alpha as 0.05 So, in this what we do is, we are first of all writing the numbers in ascending order And then we are making a table we are finding i by n ri minus So, do you have different parameters based on that we are finding D plus and D minus and then D is calculated as maximum of D plus and D minus And then further we are checking it with that chi square value from a particular table, the critical value and then we have to see that the value which we are getting for this sample It should be less than the value which we are getting from the table In that case we can say that it is uniform So, let us find So, what we see is you have Ri and if we write it in the ascending order So, Ri value will be coming like this So, in the value we have value as 0.54, 0.73, 0.98 and then 0.11 and 0.68 So, your first value will be here 0.11 Then we will have the next value as 0.54 Then we have 0.68 then we have 0.73 and then we have 0.98 Where i is 1, 2, 3, 4 and 5 Now N is 5 here So, what we see is N is 5

Now the next parameter which we are going to calculate is i upon N So, this in this case i is 1 and this is 2, 3, 4, 5 like that So, i by n will be 1 by 5, that is 0.2, 0.4, 0.6, 0.8 and 1 The next parameter which we have to find is i by N minus R i So, we are going to have the difference of this minus this That will be 0.09 This will be minus of 0.14 So, that we are not taking Then this will again be minus this will be 0.07 and this will be 0.02 Then Ri minus i minus 1 upon N Now in this case the Ri will be subtracted with i minus 1 upon n So, this will be 0.11 Now in this case 0.54 will be subtracted with 0.2, i minus 1 by N will be this one, for this value it will be this one So, 0.54 minus 0.2, 0.34, 0.68 minus 0.4, 0.28, 0.73 minus 0.6, 0.13 and 0.98 minus 0.8, 0.18 Now, after finding this we have to find D plus and D minus and then D. So, D will be D will be basically maximum of D plus and D minus Now the D plus will be basically maximum of this value So, D plus will be maximum of this row value that is 0.09 So, it will be maximum of 0.09 and maximum and D minus is this maximum of this So, in this the maximum is 0.34 So, that is 0.34 So, we are getting D as maximum of 0.09 and 0.34 that is 0.34 Now we have to find D alpha So, you have 5 readings and D alpha If you look at So, we have to look at the table we will see the Kolmogorov Simonov critical value table and in that basically for this D, alpha value of 0.05 this is the 0.565 value with 5 entries you have D alpha is coming as 0.565 So, D alpha for alpha as 0.05 and N as 5 it is given as 0.565 from Kolmogorov Simonov table Now, since this D is less than D alpha So, the hypothesis is not rejected We can say that this table the values pass the uniformity test as per this Kolmogorov Simonov conditions This the samples are from the uniform are you uniformly distributed Next question is that we have a table, we have the values and for the following data we have to use the chi square test with alpha as 0.05 to check the uniformity Now, in this case we have already understood that when the data is limited in number In that case we are going to use the Kolmogorov Simonov test; however, when the data becomes quite large in those cases the chi square test is carried out Now, in this case what we do is once we have such data

First of all, we have to convert them we have to make table we will have the intervals and then for the interval we will have the frequency and also So, we will have the frequency So, here we have 100 data So, with 100 data we know the frequency And we will also have the frequency in ideal case, that is Ei as we know that in this case we are having the chi square value being calculated and that is basically computed as So, question number 4 This is question number 3 And then we are coming to question 4 In that case we are making in such cases you are finding the interval So, here we are making 10 intervals And we will start with 0 to 0.1, 0.1 to 0.2, 0.2 to 0.3 So, we are suppose we are taking N interval 10 suppose we take 10 intervals So, interval will start from 0 to 1, 1 to 2, 2 to 0 to 0.1 sorry 0.1 to 0.2, 0.2 to 0.3 and so on So, last will be 0.9 to 1 So, you will have 10 intervals So, if we draw table you have interval So, you have interval as number 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10 Now in this case you have the observed frequency Observed frequency, once we if you try to see this table and you calculate that what is the frequency of these numbers which fall in between this interval, then you will get this values like 8, 8, 10, 9, 12, 8 ,10, 14, 10 and 11 So, this is the observed frequency in this interval Then you go to find the expected frequency Ideally what it should be because it as to be uniformly distributed And since there are 10 intervals in every interval there must be ideally 10 numbers So, it should be 10 So, it should be 10 in every interval Then what we do is further we are getting Ei, Oi minus Ei So, we get minus 2, minus 2, 0, minus 1 then 2, minus 2, 0, 4, 0 and 1 So, ultimately you have to find Oi minus Ei square upon Ei So, this will be 4 upon 10 So, it will be 0.4 It will be 0.4, it will be 0 It will be 1 upon So, it will be 0.1, it will be 4 upon 10, 0.4 0.4, it will be 0 So, it will be again 0.16 and then you will have 0 and ultimately it is 0.1 So, so once we get that So, we have to add it In fact, there is a mistake here now in this case it will be 4 into 4, 16 divided by 10 So, it will be one 1.6 in fact So, this will be 1.6 and once we add them it will be 3.4 So, summation will be 3.4 summation of this Oi minus Ei square upon Ei, where i is varying from 1 to N that is 10 In that case this is summation is coming as 3.4 Now this is your for the chi square value for this sample Now we have to see from the table, now in the table

What we see is in the table we have to see this is 0.05 and your degree of freedom because you have 10 intervals So, the degree of freedom will be 10 minus 1 So, it will be 9 and corresponding to this 9 it will be 16.9 So, what we see is we see that we are getting as 3.4 and for the sample it will be for degree for 0.05 and degree of freedom 9 it is coming as 16.9 So, what we see is this is basically less than 0.059 So, the hypothesis is not rejected it is assumed that it will pass the uniformity test So, the sample is from the uniform distribution So, the hypothesis of the uniformity is not rejected in this case So, we have seen that this is how the checking of uniformity can be carried out for such samples Thank you very much