You are on page 1of 26

Synthesis and analysis of Gaussian random variable using Matlab, and

explore the variation of:


1. Number of data (N)

2. Number of bin (N-bin)

3. Generate using normrnd

4. Generate using box-muller

5. Equal Probability Bins

1. Synthesis Gaussian random variable using randn (N,1)


At this case, we will generate a Gaussian random variable with varying number
of data (100, 1.000, 10.000 and 100.000 data). All random variables have zero mean
value and unity of variance.

a. Gaussian random variable (100,1)


Generating Gaussian random variable with 100 data and make a histogram
with 10 bins.
Matlab Program

















The values of observed frequency and expected frequency are shown in the
table. The 2 or Chi-square of random variable also can be calculated in this table
as follow.

So, by using 2 or Chi-square goodness of fit test with the formula:



The value of 2 is 4.398. By using confidence level or F(z) is 0.95 and degree
of freedom k-3 (for Gaussian distribution), from Chi-square distribution table
(appendix A) the value of 2,dof is 14,07. So, because 2 < 2,dof the random variable
is valid as a Gaussian random variable.

b. Gaussian random variable (1000,1)


Generating Gaussian random variable with 1.000 data and make a histogram
with 10 bins.

Matlab Program

















The values of observed frequency and expected frequency are shown in the
table. The 2 or Chi-square of random variable also can be calculated in this table
as follow.

So, by using 2 or Chi-square goodness of fit test with the formula:

The value of 2 is 2.722. By using confidence level or F(z) is 0.95 and degree of
freedom k-3 (for Gaussian distribution), from Chi-square distribution table (appendix
A) the value of 2,dof is 14,07. So, because 2 < 2,dof the random variable is valid as a
Gaussian random variable.

c. Gaussian random variable (10000,1)


Generating Gaussian random variable with 10.000 data and make a histogram
with 10 bins.
Matlab Program
















The values of observed frequency and expected frequency are shown in the
table. The 2 or Chi-square of random variable also can be calculated in this table
as follow.

So, by using 2 or Chi-square goodness of fit test with the formula:

The value of 2 is 12.594. By using confidence level or F(z) is 0.95 and degree
of freedom k-3 (for Gaussian distribution), from Chi-square distribution table
(appendix A) the value of 2,dof is 14,07. So, because 2 < 2,dof the random
variable is valid as a Gaussian random variable.
d. Gaussian random variable (100000,1)
Generating Gaussian random variable with 10.000 data and make a histogram
with 10 bins.

Matlab Program
















The values of observed frequency and expected frequency are shown in the
table. The 2 or Chi-square of random variable also can be calculated in this table
as follow.
So, by using 2 or Chi-square goodness of fit test with the formula:

The value of 2 is 3.820. By using confidence level or F(z) is 0.95 and degree
of freedom k-3 (for Gaussian distribution), from Chi-square distribution table
(appendix A) the value of 2,dof is 14,07. So, because 2 < 2,dof the random
variable is valid as a Gaussian random variable.

2. Synthesis Gaussian random variable by varying the number of bins (y,N)


For this case, we use zero mean Gaussian random variable with
10.000 data and varying the number of bin at 13, 16, and 19 bins. The
10.000 data is selected because at previous experiment showed an
invalid results, so the increasing number of bin makes it better or not
will be shown in this experiment.

a. Gaussian random variable (10000,1) with 13 bins


Generating Gaussian random variable with 10.000 data and make histogram
with 13 bins.
Matlab Program



















The values of observed frequency and expected frequency are shown in the
table. The 2 or Chi-square of random variable also can be calculated in this table
as follow.
So, by using 2 or Chi-square goodness of fit test with the formula:

The value of 2 is 13.25. By using confidence level or F(z) is 0.95 and degree
of freedom k-3 (for Gaussian distribution), from Chi-square distribution table
(appendix A) the value of 2,dof is 18.31. So, because 2 < 2,dof the random
variable is valid as a Gaussian random variable.

b. Gaussian random variable (10000,1) with 16 bins


Generating Gaussian random variable with 10.000 data and make
histogram with 16 bins.
Matlab Program






















The values of observed frequency and expected frequency are shown in the
table. The 2 or Chi-square of random variable also can be calculated in this table
as follow.

So, by using 2 or Chi-square goodness of fit test with the formula:


The value of 2 is 16.074. By using confidence level or F(z) is 0.95 and degree
of freedom k-3 (for Gaussian distribution), from Chi-square distribution table
(appendix A) the value of 2,dof is 22.36. So, because 2 < 2,dof the random variable
is valid as a Gaussian random variable.
c. Gaussian random variable (10000,1) with 19 bins

Generating Gaussian random variable with 10.000 data and make histogram
with 19 bins.

Matlab Program


























The values of observed frequency and expected frequency are shown in the
table. The 2 or Chi-square of random variable also can be calculated in this table
as follow.

So, by using 2 or Chi-square goodness of fit test with the formula:

The value of 2 is 19.909. By using confidence level or F(z) is 0.95 and degree
of freedom k-3 (for Gaussian distribution), from Chi-square distribution table
(appendix A) the value of 2,dof is 26.30. So, because 2 < 2,dof the random variable
is valid as a Gaussian random variable.

d. Gaussian random variable (10000,1) with 22 bins

Generating Gaussian random variable with 10.000 data and make histogram
with 22 bins.
Matlab Program

The values of observed frequency and expected frequency are shown in


the table. The 2 or Chi-square of random variable also can be calculated in
this table as follow.

So, by using 2 or Chi-square goodness of fit test with the formula:

The value of 2 is 18.120. By using confidence level or F(z) is 0.95 and degree
of freedom k-3 (for Gaussian distribution), from Chi-square distribution table
(appendix A) the value of 2,dof is 30.14. So, because 2 < 2,dof the random variable
is valid as a Gaussian random variable.

3. Synthesis Gaussian random variable using normrnd (, , N, 1)


For this case we generate a Gaussian random variable with the mean value is 7
and varying the standard deviation () at 1, 3, 5 and 7, then we evaluate the difference
of all them. All random variables have 10000 data and 10 bins of histogram.
a. Gaussian random variable (7,1,10000,1)
Generating gaussian random variable with the mean value is 7, and the
standard deviation is 1.

14
MATLAB Program


























The values of observed frequency and expected frequency are shown in the table.
The 2 or Chi-square of random variable also can be calculated in this table as
follow.
15
So, by using 2 or Chi-square goodness of fit test with the formula:

The value of 2 is 3.009. By using confidence level or F(z) is 0.95 and degree
of freedom k-3 (for Gaussian distribution), from Chi-square distribution table
(appendix A) the value of 2,dof is 14,07. So, because 2 < 2,dof the random variable
is valid as a Gaussian random variable.
b. Gaussian random variable (7,3,1000,1)
Generating gaussian random variable with the mean value is 7, and the
standard deviation is 1.

16
MATLAB Program























The values of observed frequency and expected frequency are shown in the table.
The 2 or Chi-square of random variable also can be calculated in this table as
follow.

17
So, by using 2 or Chi-square goodness of fit test with the formula:

The value of 2 is 8.194. By using confidence level or F(z) is 0.95 and


degree of freedom k-3 (for Gaussian distribution), from Chi-square distribution
table (appendix A) the value of 2,dof is 14,07. So, because 2 < 2,dof the random
variable is valid as a Gaussian random variable.

c. Gaussian random variable (7,5,1000,1)


Generating gaussian random variable with the mean value is 7, and the
standard deviation is 1.

MATLAB Program













18









The values of observed frequency and expected frequency are shown in the table.
The 2 or Chi-square of random variable also can be calculated in this table as
follow.

So, by using 2 or Chi-square goodness of fit test with the formula:

The value of 2 is 13.251. By using confidence level or F(z) is 0.95 and degree
of freedom k-3 (for Gaussian distribution), from Chi-square distribution table
(appendix A) the value of 2,dof is 14,07. So, because 2 < 2,dof the random variable
is valid as a Gaussian random variable.

19
d. Gaussian random variable (7,7,1000,1)
Generating gaussian random variable with the mean value is 7, and the
standard deviation is 1.

MATLAB Program























20

The values of observed frequency and expected frequency are shown in the table.
The 2 or Chi-square of random variable also can be calculated in this table as
follow.

So, by using 2 or Chi-square goodness of fit test with the formula:


The value of 2 is 5.657. By using confidence level or F(z) is 0.95 and
degree of freedom k-3 (for Gaussian distribution), from Chi-square distribution
table (appendix A) the value of 2,dof is 14,07. So, because 2 < 2,dof the random
variable is valid as a Gaussian random variable.

4. Synthesis Gaussian random variable using box-muller


For this case, we generate a Gaussian random variable using box-muller
formula. The Gaussian random variable is resulted by transformation of two
statistically independent random variable x1 and x2 that both uniformly
distributed on (0,1). The fransformation is

This transformation will produce zero mean and unit variance of Gaussian
random variable. The experiment is conducted by varying the number of data
(1000, and 10000) and the histogram has 10 bins.

21
a. Gaussian random variable with 1000 data
Generating Gaussian random variable using box-muller with 1000 data
of uniform random variables.

MATLAB Program




















22
The values of observed frequency and expected frequency are shown in the
table. The 2 or Chi-square of random variable also can be calculated in this table
as follow.

So, by using 2 or Chi-square goodness of fit test with the formula:


The value of is 10.586. By using confidence level or F(z) is 0.95 and degree
2

of freedom k-3 (for Gaussian distribution), from Chi-square distribution table


(appendix A) the value of 2,dof is 14,07. So, because 2 < 2,dof the random variable
is valid as a Gaussian random variable.

b. Gaussian random variable with 10000 data


Generating Gaussian random variable using box-muller with 10000 data
of uniform random variables.

23
MATLAB Program



















The values of observed frequency and expected frequency are shown in the
table. The 2 or Chi-square of random variable also can be calculated in this table
as follow.

24
So, by using 2 or Chi-square goodness of fit test with the formula:


The value of 2 is 6.527. By using confidence level or F(z) is 0.95 and degree
of freedom k-3 (for Gaussian distribution), from Chi-square distribution table
(appendix A) the value of 2,dof is 14,07. So, because 2 < 2,dof the random variable
is valid as a Gaussian random variable.

Analysis Random Variable :


1. From generated gaussian random variable in matlab with 10 bin and number of data
100,1000, 10000, 100000, we get four histogram, from our observation, the value
of chi square are 4,398; 2,722; 12,594; and 3,820 respectively, that has value 2 <
2,dof (=14,067) the random variable is valid as a Gaussian random variable. From
the histogram (100,1000, 100000) the chi square is lower, so we can see for
Gaussian if the data more larger, the curve must be narrower. For 10000, second
bin has value fo(6,751) that far from fe compare other bins, so it make the chi
square high.

2. From generated gaussian random variable in matlab with number of data 10000 and
bin of data 13,16, 19, 22, we get four histogram, from our observation, the value
of chi square are 13,25; 16,074; 19,909 ; and 18,128 respectively, that has value
2 < 2,dof , the random variable is valid as a Gaussian random variable. If we
increase the bin, increasing of degree of freedom, and value 2,dof will increase
too. So, the value acceptable for the histogram will increasing even the chi square
of each histogram increase.

3. From generated gaussian random variable in matlab using normrnd (,,N,1)


command at the same number of bin with first experiment (10 bin) produces a
smaller of Chi-square value. Using a constant 10000 data and varying standard
deviation of 1, 3, 5, and 7 produce the 2 as 3,009, 8.194, 13.251 and 5.657
25
respectively. By increasing the standard deviation of Gaussian random variable will
make the data more spread from mean value. But when the standard deviation 7 the
value decrease.

4. We generate Gaussian random variable using box-muller method in Matlab. In our


observation, increasing the number of data will decrease the value of Chi- square
(2). Using of 1000 and 10.000 data produce the 2 as 10.586 and 6.527 respectively.
That has value 2 < 2,dof (=14,067). So for large number of data, box muller can
valid as a Gaussian random variable

26

You might also like