MAKAUT CA3 2023 Mandatory (New Rules) View

# Python and Statistics for Financial Analysis Coursera Quiz Answers ✅ [Assignment + Quiz]

Table of Content Python and Statistics for Financial Analysis - Coursera Quiz Answers and Course Review

 Course Name Python and Statistics for Financial Analysis Course Type MOOCS (Massive Open Online Courses) Conducted by Hong Kong University of Science and Technology Online Course Platform COURSERA.org Financial Aid Avaliable Yes Course Commitment 4 weeks of study, 3-4 hours/week Course Language English Course Level Intermediate (for College Students) Course Rating ⭐⭐⭐⭐⭐ (4.4) | 2898 Reviews

 ▶️ Introduction Video - Python and Statistics for Financial Analysis
Python and Statistics for Financial Analysis ⭐⭐⭐⭐⭐(4.4) | 2898 Rating Hong Kong University of Science and Technology

## QnA: Week wise Quiz Questions and Answers

Python and Statistics for Financial Analysis - Coursera Quiz Answers ✅ | Coursera Moocs Quiz Answers

### Week 1- Quiz 1 Answers

WEEK-1 Topic
Visualizing and Munging Stock Data

1.Question 1

Which of the following library has DataFrame object?

✅ Pandas

2. Question 2

Which of the following is the correct way to import a library, eg Pandas?

✅ import pandas as pd

3. Question 3

What is the method of DataFrame object to import a csv file?

✅ from_csv()

4. Question 4

Which of the following attributes of a Data Frame return a list of column names of this DataFrame?

✅ Columns

5. Question 5

Which of the following can slice ‘Close’ from ‘2015-01-01’ to ‘2016-12-31’ from data, which is a DataFrame object?

✅ data.loc[‘ 2015-01-01’:’2016-12-31 ‘Close’]

6. Question 6

What is the method of DataFrame to plot a line chart?

✅ plot()

7. Question 7

Suppose you have a DataFrame - data, which contains columns ‘Open’, ‘High’, ‘Low’, ‘Close’, ‘Adj Close’ and ‘Volume’.

What does data[[‘Open’, ‘Low’]] return?

✅ Columns ‘Open’ and ‘Low’

8. Question 8

Suppose you have a DataFrame ms , which contains the daily data of  ‘Open’, ‘High’, ‘Low’, ‘Close’, ‘Adj Close’ and ‘Volume’ of Microsoft's stock.

Which of the following syntax calculates the Price difference, (ie ‘Close’ of tomorrow – ‘Close’ of today)?

✅ ms[‘Close’].shift(-1 ms[‘Close’].shift(-1)

9. Question 9

Suppose you have a DataFrame - ms , which contains the daily data of  ‘Open’, ‘High’, ‘Low’, ‘Close’, ‘Adj Close’ and ‘Volumn’ of Microsoft's stock.

What is the method of DataFrame to calculate the 60 days moving average?

✅ rolling(60).mean()

10. Question 10

Which of the following idea(s) is/are correct to the simple trading strategy that we introduced in the lecture video?

• If fast signal is larger than slow signal. this indicates an upward trend at the current moment
• Use longer moving average as slow signal and shorter moving average as fast signal

### Week 2 - Quiz 2 Answers

WEEK-2 Topic
Random variables and distribution

1. Question 1

Roll two dice and X is the sum of faces values. If we roll them 5 times and get 2,3,4,5,6

Which of the following is/are true about X?

✅ X is a random variable

2. Question 2

Roll two dice and X is the sum of faces values. If we roll them 5 times and get 2,3,4,5,6

What do we know about X?

✅ We have 5 observations of X

3. Question 3

Roll two dice and X is the sum of faces values. If we roll them 5 times and get 2,3,4,5,6
X is a ________ random variable.

✅ Discrete

4. Question 4

Why do we use relative frequency instead of frequency?

✅ Relative frequency can be used to compare the ratio of values between difference collections with difference number of values

5. Question 5

What can we say about relative frequency when we have large number of trials?

✅ Relative frequency becomes approximately the distribution of the corresponding random variable

6. Question 6

What is the notion of  "95% Value at Risk" ?

✅ 95% VaR measures the amount of investment you can lose, at the worst 5% scenarioa

7. Question 7

In the lecture video, we mentioned the calculation of continuous random variable is based on the probability density function. Given a probability density function, f(x) = 1/100, what is the probability

P(10<X<20), where X~Uniform [0, 100]?

✅ (20- 10) * 1/100

8. Question 8

What methods should we use to get the cdf and pdf of normal distribution?

✅ norm.cdf() and norm.pdf() from scipy.stats

9. Question 9

Which additional library should we import when we want to calculate log daily return specifically?

✅ Numpy

10. Question 10

What is the distribution of stock returns suggested by Fama and French in general?

✅ Close to normal distribution but with fat tail

### Week 3 - Quiz 3 Answers

WEEK-3 Topic
Sampling and Inference

1. Question 1

What is true about sample and population?

✅ Sample is a subset of population which is randomly draw from population

2. Question 2

You have a DataFrame called ‘data’ which has only one column ‘population’.
data = pd.DataFrame()
data[‘population’] = [47, 48, 85, 20, 19, 13, 72, 16, 50, 60]
How to draw sample with sample size =5, from a ‘population’ with replacement?

(Hint: You can modify the code illustrated in the Jupyter Notebook "Population and Sample" after Lecture 3.1)

✅ data[‘population’].sample(5, replace=True)

3. Question 3

Why is the degrees of freedom n-1 in sample variance?

✅ The degrees of freedom in sample variance is constrained by the sample mean

4. Question 4

What does Central Limit Theorem tell you about the distribution of sample mean?

✅ The distribution of sample mean follows normal distribution with very large sample size follows normal distribution regardless of the population distribution

5. Question 5

Suppose we have 3 independent normal random variables X1, X2 and X3:
What is the distribution of X1 + X2 + X3?

✅ Mean and variance of X1, X2 and X3 are added up 6. Question 6

Why do we need to standardize sample mean when making inference?

✅ The standardized distribution of sample mean follows N(0,1) which is easier to make inference

7. Question 7

What can a 95% confidence interval of daily return of an investment tell you?

✅ With 95% chance this interval will cover the mean of daily return

8. Question 8

Check the Juypter notebook of 3.3 Sample and Inference. What is the confidence interval of this exercise?

✅ [ - 0.000015603, 0.001656]

9. Question 9

When do you reject a null hypothesis with alternative hypothesis μ>0 with significance level α?

• p value is smaller than α
•  z < z_(1-α)

10. Question 10

When doing analysis of stock return, you notice that with 95% confidence interval, the upper bound and lower bound are negative.

✅ There is 95% chance of which the mean return of this stock is negative

### Week 4 - Quiz 4 Answers

WEEK-4 Topic
Linear Regression Models for Financial Analysis

1. Question 1

Why do you use coefficient of correlation, instead of covariance, when calculating the association between two random variables ?

✅ Covariance can be affected by the variance of individual variables, but coefficient of correlation is rescaled by variance of both variables

2. Question 2

What is the range and interpretation of coefficient of correlation?

✅ From -1 to 1, -1 means perfect negative linear relationship and 1 means perfect positive linear relationship

3. Question 3

Refer to the https://www.coursera.org/learn/python-statistics-financial analysis/notebook/F0Luf/simple-linear-regression-model
Is LSTAT a significant predictor of MEDV at significance level 0.05?

✅ Yes, because the p value of b_1 is smaller than 0.05

4. Question 4

To evaluate the performance of linear regression model, we refer to the summary of "model" as seen in https://www.coursera.org/learn/python-statistics-financial-analysis/notebook/F0Luf/simple-linear-regression-model
What is the percentage of variation explained by the model ?

✅ 0.54

5. Question 5

How to check if a linear regression model violates the independence assumption?

✅ Durbin Watson test

6. Question 6

If any of the assumptions of linear regression model are violated, we cannot use this model to make prediction.

✅ False

7. Question 7

Check the Jupyter Notebook 4.4- Build the trading model by yourself!
We have a variable ‘formula’ which store the names of predictors and target. How should you modify this ‘formula’ if you want to drop the predictor ‘daxi’?

✅ formula = ‘spy~aord+cac40+nikkei+dji’

8. Question 8

Check the Jupyter Notebook 4.4- Build the trading model by yourself !

What is the most significance predictor for ‘SPY’?

✅ arod

9. Question 9

What does it mean if you have a strategy with maximum drawdown of 3%?

✅ During the trading period, the maximum drop from the previous peak of your portfolio value is 3%

10. Question 10

✅ Define some metric for evaluating your strategy, eg Sharpe Ratio, maximum drawdown. Then split your data into train set and test set and check if your strategy can generate positive return using both train set and test set