top of page

COSC380 COSC580/COMP2400 Relational Databases/
MAF203 Business Finance/CITS1401 Computational Thinking with Python

For solutions, purchase a LIVE CHAT plan or contact us

Question 1: (Maximum Likelihood and Error Bars) [30 marks]
Submit your working in 1(a) and 1(b) as an appropriate file (text, doc, or pdf),
and your Matlab codes in Q2 and Q3 as requested. Zip or tar these files into a
single file to submit via Moodle.
(a) The log-normal probability density function normalized over the half-interval
[0,∞) is given by:
P(x|µ,σ) =
1
xσ √ 2π
exp
?
− (lnx − µ)
2
2σ 2
?
.
Find the value of µ that maximizes the log-likelihood function for N i.i.d. data
points {x 1 ,...,x N } at a fixed value of σ. Simplify your expression and show
all working.
(b) Now find the error bars (Slide 56 of Module 2) on this estimate of µ. How
do the error bars behave as the number of data points increases?
Question 2: (Soft K-means Algorithm for Clustering) [40 marks]
Continue on from Lab 2, and use Matlab to implement the following extensions
to the K-means algorithm. Using a pair of two-dimensional Gaussians, test your
implementations on the data from old faithful.dat by plotting your Gaussians
for each question part. Label your Matlab files my mix1.m for 2(a), my mix2.m for
2(b), and my mix3.m for 2(c) so that I know when marking.
(a) Implement the soft K-means algorithm given in lectures for two Gaussians,
each with a fixed diagonal covariance matrix, and update only the mean and
responsibilities for each Gaussian. Note that the simplest choice of diagonal
covariance matrix given by:
Σ =
? 1
0
0 1
?
is not a good choice because the data in old faithful.dat has a range of
3.5 along one dimension, and 53 along the other. The squared ratio of these
ranges is (53/3.5) 2 ≈ 229. The variance along each dimension of the data
should therefore maintain this ratio. For example, one possibility is given
by:
Σ =
? 0.1
0
0 22.9
?
(b) Now build on 1(a) to develop a soft K-means algorithm where each of the
Gaussians has a diagonal covariance matrix given by,
Σ k =
? σ 2
k
0
0 σ 0
k
2
?
1
and where the four variance parameters σ 2
1 ,σ
0
1
2 ,σ 2
2
and σ 0
2
2 , as well as two
mixing coefficients π 1 and π 2 are now updated at each iteration using the
maximum likelihood results derived in lectures for the univariate Gaussian.
In this case, simply replace the scalar values x n and µ k in each of the formulas,
with the vector values x n and µ k . Note that the scalar variance ˆ σ 2
k
then
becomes a vector: ˆ σ 2
k
= [σ 2
k ,σ
0
k
2 ].
(c) Making use of the results from 1(b), now implement the full Gaussian mixture
model given in lectures (The EM algorithm for Gaussian mixtures). Each
Gaussian now has a full covariance matrix, each with four parameters, that
must be learned from the data.
Question 3: (Metropolis Sampling and Random Walks) [30 marks]
Using Matlab, implement a Markov chain using the Metropolis method given in
the lectures. Label your Matlab file my metropolis.m.
(a) Use your implementation to generate samples from the target distribution
P(X) given below. I suggest using a proposal distribution consisting of a
spherical Gaussian (diagonal covariance matrix) with variance ? 2 . Plot your
samples and overlay a contour plot of the target distribution.
% Define and plot target distribution
mu = [0 0]; % mean
rho = 0.998;
sigma = [1 rho; rho 1]; % covariance matrix of target
P = @(X) mvnpdf(X, mu, sigma); % X is implicitly a vector in R2
x1 = linspace(-1, 1);
x2 = x1;
[x1 x2] = meshgrid(x1, x2);
Pcontour = reshape(P([x1(:), x2(:)]), 100, 100);
figure(1); clf; contour(x1, x2, Pcontour, [1.6 3], ‘k’); axis square
% Metropolis algorithm
% Plot samples
(b) This target distribution is an especially nasty distribution to sample from, so
we would like to know how many Metropolis steps we need to take to generate
an approximately independent sample. We therefore need to analyse random
walk behaviour as we did in lectures. Keeping the sample acceptance rate
at around 0.5 (for maximum information transfer), how many steps does
it take to generate an approximately independent sample? (for example,
by exploring the entire length of the contour plot). Does this agree with
what you expect using the “rule of thumb” derived in lectures? (There are
several ways you can implement this rule involving either lengthscales or
covariance matrices). You can also look at the sample autocorrelation by
downloading the Matlab function acf.m from Moodle. This function can be
called as acf(data, lag); where data is a vector of data, and lag is a single
number, such as the total number of steps you take in one Metropolis run.

=======================================================================================

COMP2400 Relational Databases
23:59, 30 August, 2022

Question 1 20 Marks
The relational database moviedb has the following database schema:
Movie(title, production year, country, run time, major genre)
primary key : {title, production year}
Person(id, first name, last name, year born)
primary key : {id}
Award(award name, institution, country)
primary key : {award name}
Restriction Category(description, country)
primary key : {description, country}
1

Director(id, title, production year)
primary key : {title, production year}
foreign keys : [title, production year] ⊆ Movie[title, production year]

[id] ⊆ Person[id]
Writer(id, title, production year, credits)
primary key : {id, title, production year}
foreign keys : [title, production year] ⊆ Movie[title, production year]

[id] ⊆ Person[id]
Crew(id, title, production year, contribution)
primary key : {id, title, production year}
foreign keys : [title, production year] ⊆ Movie[title, production year]

[id] ⊆ Person[id]
Scene(title, production year, scene no, description)
primary key : {title, production year, scene no}
foreign keys : [title, production year] ⊆ Movie[title, production year]
Role(id, title, production year, description, credits)
primary key : {title, production year, description}
foreign keys : [title, production year] ⊆ Movie[title, production year]

[id] ⊆ Person[id]

Restriction(title, production year, description, country)
primary key : {title, production year, description, country}
foreign keys : [title, production year] ⊆ Movie[title, production year]

[description, country] ⊆ Restriction Category[description, country]

Appearance(title, production year, description, scene no)
primary key : {title, production year, description, scene no}
foreign keys : [title, production year, scene no] ⊆ Scene[title, production year, scene no]
[title, production year, description] ⊆ Role[title, production year, description]

Movie Award(title, production year, award name, year of award, category, result)
primary key : {title, production year, award name, year of award, category}
foreign keys : [title, production year] ⊆ Movie[title, production year]

[award name] ⊆ Award[award name]

Crew Award(id, title, production year, award name, year of award, category, result)
primary key : {id, title, production year, award name, year of award, category}
foreign keys : [id, title, production year] ⊆ Crew[id, title, production year]

[award name] ⊆ Award[award name]

Director Award(title, production year, award name, year of award, category, result)
primary key : {title, production year, award name, year of award, category}
foreign keys : [title, production year] ⊆ Director[title, production year]

[award name] ⊆ Award[award name]

Writer Award(id, title, production year, award name, year of award, category, result)
primary key : {id, title, production year, award name, year of award, category}
foreign keys : [id, title, production year] ⊆ Writer[id, title, production year]

[award name] ⊆ Award[award name]

Actor Award(title, production year, description, award name, year of award, category, result)
primary key : {title, production year, description, award name, year of award, category}
foreign keys : [award name] ⊆ Award[award name]

[title, production year, description] ⊆ Role[title, production year, description]

There are five different categories of awards: movie awards, crew awards, director awards, writer awards and actor
awards. A movie can only win an award after being nominated for the award.
Your task is to answer the following questions using SQL queries. For each question, your answer must be a single
SQL query that may contain subqueries, and you must write your answers into the template file myqueries.sql.
1.1 List the ids of persons whose last name starts with ‘Y’.
1.2 How many movies were categorised in the ‘PG-13’ restriction in USA? List that number.
1.3 How many writers were born after 1930 (inclusive)? List that number.

1.4 How many restriction categories each country has? List the countries and the corresponding numbers of restric-
tion categories. Order your result in the descending order of the numbers of restriction categories.

1.5 How many directors have never directed any action movies (i.e., the major genre of the movie is action)? List
that number.
1.6 How many movies were co-written by exactly two writers? List that number.
1.7 What is the percentage of Australian movies (i.e., movies produced in Australia) among all movies in this
database? List the percentage as a decimal (round to two decimal places). Hint: in PostgreSQL, the function
ROUND(x, n) can round x to n decimal places, e.g., if x=0.1129, then ROUND(x, 2) = 0.11.
1.8 Which movie(s) won the largest number of crew awards in a single year? List their title(s) and production
year(s).
1.9 How many movies have never won any award (including movie awards, crew awards, director awards, writer
awards and actor awards)? List that number.
1.10 Which director(s) directed the largest variety of movies (i.e., the largest number of distinct major genres)? List
their id(s).

========================================================================================

MAF203 Business Finance
15 September 2022 by 8:00PM AEDT

Part 1 – About the Company (25 marks) (up to 600 words)
1. Download the 2021 Corporate Governance Statement of ANZ group from the unit site.
Carefully study the board of directors of the firm. Evaluate the effectiveness of the
board. Explain your answer clearly. What is the advantage of having an effective board?
(15 marks)
2. Based on the 2021 annual review (which is an abbreviated version of the annual
report), what steps has ANZ Group undertaken to minimise its environmental impact?
In your view, what other actions could ANZ Group take to minimise its environmental
effects further? (5 marks)
3. What support did ANZ Group provide to its customers in response to the COVID-19
pandemic? In your opinion, is this support enough, or should ANZ Group do more to
help its customers further? (5 marks)
Part 2 – Assessing risk and return (25 marks) (up to 600 words)
You are required to form a two-asset portfolio from the stock and the index shown below. The
data is provided under the assessment folder on the unit site. For the portfolio, answer the
following questions:

ASX Code Company/Index Name
ANZ.AX ANZ Group
^AORD All Ordinary index

(MKT)

1. Calculate annualised expected return and standard deviation of the stock and the
index given above. Keep two to three decimal points.
2. Calculate the correlation between the stock and the index.
3. Calculate the beta of ANZ Group. How would you interpret the beta of ANZ Group?
4. Which of the risks identified in ANZ’s annual review (pages 54 and 55) will affect its
beta? Which of the risks identified there will affect ANZ’s unsystematic risks? Explain
clearly.
5. Calculate the expected return and standard deviation of the portfolio constructed from
the stock and the index using the weights below. Use the annualised expected return
and standard deviation calculated in Part 2 Q (1) to calculate expected portfolio return
and risk for the below questions wherever appropriate.
Weight of
ANZ.AX

Weight of
^AORD

Portfolio
risk

Portfolio
Return

0.0 1.0
0.1 0.9
0.2 0.8
0.3 0.7
0.4 0.6
0.5 0.5
0.6 0.4
0.7 0.3
0.8 0.2
0.9 0.1
1.0 0.0

6. Calculate the excess portfolio expected return per unit of risk 1 for each combination of
weights. The excess portfolio expected return is the difference between the portfolio’s
expected return and the risk-free rate. Assume the risk-free rate is 3.5%, which is the
current 10-year Australian government bond coupon rate. Explain your answer clearly
and show your workings.
7. Which combination maximises excess portfolio expected return per unit of risk? What
is the economic interpretation for this combination?
8. Calculate the expected return of ANZ’s share using the Capital Asset Pricing Model.
1 The excess portfolio expected return per unit of risk is also called the Sharpe ratio.

Part 3 – ANZ Valuation based on the Discounted Dividend Model (20 marks) (up to 600
words)
Please download the excel spreadsheet from the unit website which shows the dividend history of
ANZ Group from 2012 to 2021.
Calculate the intrinsic (theoretical) share price for ANZ based on the “two-stage” variable growth
model. Need to show the steps of your calculations. How do you make the assumptions regarding
the key parameters?
Hint: Part 2 of this assessment can provide some of the input(s) required to estimate the value of
ANZ’s share.

Part 4 – Relative Valuation (15 marks) (up to 600 words)
The following table shows the relevant statistics for several firms in the banking and financial
sector in Australia. Calculate the share price of ANZ Group using the relative valuation approach
based on the data below.
  ASX code Earnings Number of shares
outstanding

Share Price End of
Period 2021
NAB NAB.AX $ 6,810 million 3,180 million $27.13
CBA CBA.AX $ 9,830 million 1,700 million $93.74
Westpac WBC.AX $ 5,290 million 3,500 million $20.30
ASX ASX.AX $ 489.4 million 193.6 million $83.19
Magellan
Financial

MFG.AX $314.5 million 185.1 million $18.61
QBE Insurance QBE.AX $ 700 million 1,480 million $11.13
ANZ Group ANZ.AX $6,760 million 2,800 million $26.53

Part 5 – Is ANZ Group overvalued or undervalued? (15 marks) (up to 600 words)
1. In Part 2 Q (1), your group calculated the expected return of ANZ shares using daily stock price
data. In Part 2 Q (8), your group calculated the expected return of ANZ shares using the capital asset
pricing model. Based on this comparison, is ANZ’s share overvalued or undervalued? Explain clearly.
2. In Part 3 Q (2), your group calculated the share price of ANZ using the dividend discount model.
The share price of ANZ at the end of 2021 was $26.53. Based on the above information, is ANZ
overvalued or undervalued? Explain clearly.
3. In Part 4, your group calculated the share price of ANZ using the relative valuation model. The
share price of ANZ at the end of 2021 was $26.53. Based on the above information, is ANZ
overvalued or undervalued? Explain clearly.
4. Provide your group’s conclusion on whether ANZ’s share is overvalued or undervalued. Explain
your answer clearly.

======================================================================================================

CITS1401 Computational Thinking with Python
5:00 pm, Friday 16th September, 2022

Overview
Face recognition (FR) is one the most widely known and used non-intrusive biometric which helps in
identifying people. Given the identity of a known person, the goal of an FR system is to recognize the same
person in a different scenario, for example while displaying a different expression. You can read this paper
to understand more about FR under different expressions.
Your task is to help the researchers in analysing eight geodesic (surface) and eight 3D Euclidian distances
between a few facial landmarks across four expressions 'Neutral', 'Angry', 'Disgust', 'Happy'. These
distances on one face (in Neutral expression) can then be used to calculate similarity with the same face in
different expressions or with other faces in the data set to see which faces are closer to (or look like) the
reference face. Table 1 provides the details of each landmark while Figure 1 shows their location on the
face. Table-2 gives you the details of the distances which will be used.
The attached csv (comma separated values) file has the eight geodesic and 3D Euclidian distances for the
four expressions mentioned above for each person. For the sake of simplicity, the Distance numbers are
given instead of their names. For example, Inner-canthal width is distance number 1 and Lower jaw width
is distance number 8. Yourtask istowrite a programwhich fulfills the following requirements.

Table 1: Details of the Facial landmarks.
Landmark
Name

Location
Ex Outer eye corners
En Inner eye corners
N Nasal root
Ft Temple points
Al Outer edge of nostrils
Ch Outer mouth corners
Go Joint between the two jaws
Prn Nose Tip
Ls Midpoint of upper lip
Li Midpoint of lower lip
Sto Midpoint of both lips

Distance Facial distance LM1 LM2
1 Inner-canthal width En_L En_R
2 Outer-canthal width Ex_L Ex_R
3 Nasal bridge length N Prn
4 Nose width Al_L Al_R
5 Upper Lip thickness Ls Sto
6 Lower Lip thickness Sto Li
7 Forehead width FT_L FT_R
8 Lower jaw width Go Go

Requirements (i.e. what your program should do)
Input:
Your program must define the function main with the following syntax:
def main(csvfile, adultID, Option):
The input arguments to this function are:
• csvfile: The name oftheCSVfilecontaining the data of individuals which needs to be analysed.
Below are the first two rows of a sample file.
Adult ID Expression Distance GDis LDis
E001 Neutral 1 48.44795743 32.13047933
The first row of the CSV file contains the headers “Adult ID”, “Expression”, “Distance”, “GDis” and
“LDis”. From the second row, the first value of each row contains the de-identified adult ID, the
expression displayed by the face, distance number (refer to Table-2), the geodesic distance and
the 3D Euclidean distance. We do not have prior knowledge about the number of subjects we
have to analyse (i.e. the number of rows) that the CSV file contains. Adult ID and Expression are
strings, Distance is an integer while the remaining values are floats.
• adultID: The ID number of the adult we have to analyse. Remember that the ID is a string and
is case sensitive.

Table 2: List of distances used in this
project. For example, Forehead width is the
distance between Left Forehead (FT_L) and
Right Forehead (FT_R). Similarly Inner
canthal width, is the distance between the
two inner eye corners: En_L and En_R.
Figure 1: Facial landmarks locations on face

• Option: The input argument that decides the type of analysis required. It can take only one of
the two string inputs: “stats” or “FR”. Ifthe third input argument is “stats”, then the objective
of the program is to carry out some statistical analysis of the adult whose ID is given in the second
argument. Otherwise, if the third input argument is “FR” then the objective is to perform face
recognition by calculating the cosine similarity between the reference ID and other subjects.
Output:
The function is required to return the following outputs in the order provided below:
When the third input argument is “stats” then for the adult given in the input argument “adultID”
1. OP1- A list of lists containing the minimum (non-zero) and maximum GDis and LDis of each distance
across the four expressions. For example, the minimum (non-zero) intercanthal width (geodesic and 3D
Euclidean) in Neutral, Angry, Disgust and Happy expressions. There will be 8 lists inside the main list
and each list will have four elements in the following order : [minimum GDis, maximum GDis, minimum
LDis, maximum LDis]. The distances must be in the same order as given in Table-2.
2. OP2- A list of lists containing the difference between the geodesic and 3D Euclidean distances for each
expression. There will be 4 lists inside the main list and each list will have eight elements.
3. OP3- A list containing the average geodesic distance of the eight distances across the four expressions.
This list will have 8 elements.
4. OP4- A list containing the standard deviation of the 3D Euclidean distance of the eight distances across
the four expressions. This list will have 8 elements. The formula to calculate standard deviation is
provided at the end of this project sheet.
When the third input argument is “FR”:
You will calculate the cosine similarity between the geodesic distances of the neutral expression of
reference adultID and the geodesic distances of the remaining expressions of the same ID as well as the
neutral expressions of the remaining subjects in the dataset. Your output will be:
1. The ID of the person with which the reference face has the maximum cosine similarity, and
2. The maximum cosine similarity value. The formula to calculate cosine similarity is provided at the end
of this project sheet.
All returned lists should have the values in order. For example, for OP2, the main list has 4 sub-lists which
should be ordered according to the expressions 'Neutral', 'Angry', 'Disgust', 'Happy'. Inside each sub-list
are 8 elements for the distances which must be ordered as per Table-2. All returned numeric outputs (both
in lists and individual) must contain values rounded to four decimal places (if required to be rounded off).
Do not round the values during calculations. Instead round them only at the time when you save them into
the final output variables.
Examples:
Download the ExpData_Sample.csv file from the folder of Project 1 on LMS or Moodle. Some examples of
how you can call your program from the Python shell (and examine the results it returns) are:
>>> OP1,OP2,OP3,OP4 = main('ExpData_Sample.csv','E001','stats')
>>> OP1
[[45.0087, 48.448, 29.9972, 32.9404], [104.1724, 110.913, 93.9636,
98.5776], [33.9933, 39.7572, 34.695, 40.0872], [49.5445, 66.477,

31.0483, 34.1107], [5.5607, 9.7036, 5.4345, 9.3448], [7.4147, 8.9331,
7.4147, 8.7645], [150.0258, 175.289, 118.1052, 127.0695], [137.8113,
154.4196, 107.0492, 111.6436]]
>>> OP2
[[16.3175, 10.2088, -0.5075, 34.6928, 0.3588, 0.0187, 48.2195, 46.5544],
[15.2932, 12.3354, -0.33, 18.4962, 0.1669, 0.1686, 39.2716, 45.8233],
[13.1529, 9.3969, -0.7016, 27.0089, 0.3791, 0.0, 39.5195, 36.9674],
[15.4137, 10.9684, -0.6347, 24.5052, 0.1262, 0.2101, 31.9206, 26.9959]]
>>> OP3
[46.7753, 106.8638, 37.9698, 58.3879, 7.5469, 8.1489,160.8882, 148.6113]
>>> OP4
[1.0775, 1.6565, 2.2229, 1.1442, 1.408, 0.6276, 3.5032, 1.8129]
>>> ID,cossim = main('ExpData_Sample.csv','E001','FR')
>>> ID
'A004'
>>> cossim
0.9992

For solutions, purchase a LIVE CHAT plan or contact us

Limited time offer:

Follow us on Instagram and tag 10 friends for a $50 voucher! No minimum purchase required.

bottom of page