Professional Documents
Culture Documents
IMPORTANT: The teachers of this course apply a ‘zero tolerance’ policy regarding academic
dishonesty. Students that sign up this document agree to deliver an original work. The breach
of this commitment will result in academic punishment.
Observations:
Solve the exercises in the Assignment1.pdf file. Note: It is advisable to consult the
manual for basic operation of MATLAB / Octave available on the website of the course.
_______________________________________________________________
1. a) Calculate the frequency table of variable Area. The table must include the absolute,
relative, cumulative absolute and cumulative relative frequencies.
abs_acum =
178
329 We can calculate cumulative
478 frequencies by means of command
cumsum.
>> rel_acum = cumsum(table(:,3))
rel_acum =
3rd column: relative
37.2385
68.8285
100.0000
___________________________________________________________________________
Telecommunications Engineering – Statistics – Academic year 2018/2019
4.- Analyse the variables Gender and Goals in a double entry table. Calculate the absolute
frequency table with its marginal distributions and the relative frequency table with its
marginal distributions. (1.5 points)
a)
In this double entry table, the rows represent the gender and the columns represents the
goals (for example, the gender 1 with the goal 1 happens to be 117 times).
b)
We know the absolute frequency of a type of element is the number of times that element is
repeated, and the relative frequency is that number divided into the total number of
elements. Therefore, we can observe when tabulating both variables the absolute frequency
of each value is on the column “count” (for example, regarding the Goals the value 1 is
repeated 247 times).
On the other hand, the relative frequency is located on the “Percent” column, where we can
see the proportion of that variable with respect to the others (in this case the relative
frequency would be Percent/100)
___________________________________________________________________________
Telecommunications Engineering – Statistics – Academic year 2018/2019
2. Linear Transformations
1. Change of units. Consider the matrix internet in the file internet.mat, and consider the
variable MB (“downloaded Mb”). Define a new variable, KB, as the nº of downloaded
Kb, recall “1Mb = 1024Kb”. The new variable is the result of a linear transformation of
the form y = a + bx. From this transformation, check with MATLAB/Octave the next
theoretical relations: (2 points)
a) y = a + bx.
___________________________________________________________________________
Telecommunications Engineering – Statistics – Academic year 2018/2019
Complete frequency table
table = Area:
The school is in an
1.0000 178.0000 37.2385 178.0000 37.2385 1 = urban,
2.0000 151.0000 31.5900 329.0000 68.8285 2 = sub-urban, or
3.0000 149.0000 31.1715 478.0000 100.0000 3 = rural area.
2.a) What is the proportion of boys and girls? Represent graphically that proportion with a
bar and a pie chart.
Relative
>> table = tabulate (Gender)
Gender Absolute frequency
(1 = Boys frequency (percent)
table =
2 = Girls) (count) -
PROPORTION
1.0000 227.0000 47.4895
1.0000 227.0000 47.4895
2.0000 251.0000 52.5105
2.0000 251.0000 52.5105
>> bar(table(:,3))
>> pie(table(:,3))
Boys Girls
___________________________________________________________________________
Telecommunications Engineering – Statistics – Academic year 2018/2019
b) What is the proportion of boys and girls whose schools are established in urban areas?
%First, we create a matrix with 2 columns, the first one represents the Gender and the
second, the Area. In other words, we join the Gender and Area vectors in a single matrix in
order to compare the values
%Then, we create a vector (with 478 elements(total)) called “Boys_urban” that will have 1s
when the following conditions are met: first column is a 1 (Boy) and second column is also
a 1 (Urban Area).
Boys_urban =
72
%Now, we sum all the 1s in our Boys_urban vector (Therefore, counting how many boys
live in urban areas)
Boys_urban_percent =
31.7181
Girls_urban =
106
Girls_urban_percent =
42.2311
Therefore, the proportion of boys whose schools are established in urban areas is
31.7181% and the proportion of girls is 42.2311%
___________________________________________________________________________
Telecommunications Engineering – Statistics – Academic year 2018/2019
3. a) Do histograms of the variables Grade and Age by the variable Goals.
b) Calculate the mean and the standard deviation of the variables Grades and Sports by Age
groups.
>> >>
As we have
[MEANS,STDS]=grpstats(Grades,Age) created a histogram by groups, which means we are considering
[MEANS,STDS]=grpstats(Sports,Age)
various variables when performing the calculations, the mean and the standard
MEANS = deviation cannot be calculated
MEANSwith= the average commands mean(x) and std(x).
To calculate statistics by groups, we will make use of the command grpstats.
1.0000 We can perform different2.0000
operations within the same command, as it is written
2.3800 above 2.3400
2.3485 2.0379
2.8571 2.0582
2.9038 1.8077
2.7500 2.2500
STDS = STDS =
0 0
0.1117 0.0997
0.0860 0.0870
0.0782 0.0692
0.1353 0.1318
2.
0.7500 0.6292
___________________________________________________________________________
Telecommunications Engineering – Statistics – Academic year 2018/2019
2. Linear Transformations
1.
2. Standardization of variables. Consider the variable MB, and denote it as x. Define a new
variable y as the result of the standardization of x. The standardization consist to apply a
linear transformation such that subtracts the mean value and divides by its standard
deviation. The resulting variable has zero mean, and standard deviation and variance equal
to one.
>> MB=internet(:,1)
In the file internet.mat, which we need to (1)
import into our workspace to do the MB =
practice, we have a matrix with 4 columns. …
The first column corresponds to the
variable MB. To denote it as x, first we
isolate it as a single variable (1), and then >> x=MB
we simply create the variable x and make it
equal to MB (2). x=
…
(2)
a= b=
-21.2252 b) 0.1215
b) Obtain the new standardized variable y and check in MATLAB/Octave, the next results:
___________________________________________________________________________
Telecommunications Engineering – Statistics – Academic year 2018/2019
y = 0, s^2 y = 1 y sy = 1.
-1.9446e-15 1 1
When we open the file internet.mat we find a 95x4 matrix, where the first column
corresponds to MB and the second to the connection time in hours. So first, we create the variables
x for the downloaded MB and v for the connection time in hours:
>> x = internet(:,1)
LINEAR TRANSF. REQUIRED:
>> v = internet(:,2) y = a + bx & u = c + dv
Then, we make the required conversions and create 2 new variables, y and u:
b = 1024 d = 3600
___________________________________________________________________________
Telecommunications Engineering – Statistics – Academic year 2018/2019
ρy,u = >> corrcoef(y,u)
Therefore, we have check that the following expression is, in
ans = fact, true:
1.0000 0.7686
0.7686 1.0000
___________________________________________________________________________
Telecommunications Engineering – Statistics – Academic year 2018/2019