Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee

Human-written only.

24/7 Support

Anytime, anywhere.

Plagiarism Free

100% Original.

Expert Tutors

Masters & PhDs.

100% Confidential

Your privacy matters.

On-Time Delivery

Never miss a deadline.

Assignment 4 Implement for both SPY and your stock i

Computer Science May 06, 2022

Assignment 4

Implement for both SPY and your stock i.e. CRM

A set of numbers satisfies Bernford’s law if the leading digit d occurs with probability

Therefore, the frequency distribution of the leading digit d in such a set is the following: π1 = 30.1%, π2 = 17.6%, π3 = 12.5%, π4 = 9.7%, π5) = 7.9%, π6, π7 = 5.8%, π8 = 5.1% and π9 = 4.6%.

In this assignment, you will examine this law when applied to a large online retail dataset. You have price data in ”on- line retail.csv” for about 500,000 items from different countries. You will ignore all items that start with 0.

You compute the real distribution F = (f1, f2, . . . , f9) of frequencies of the leading digit in these prices and compare F to two models:

1. Model 1: equal-weight distribution: each leading digit has the same frequency 1/9 = 11.1%. In other words, your

predicted model of frequencies in this model is a 9-digit vector P = (1/9,1/9,...,1/9)

2. Model 2: leading digit follows the Bernford’s law. In this model, the prediction is a 9-digit vector π = (π1, π2, . . . , π9)

Questions:

  1. plot 3 histograms for the frequencies for real distribution, equal-weight and Bernford (for each digit)
  2. plot 3 histograms for the relative errors for Models 1 and 2 (for each digit)
  3. compute RMSE (root mean squared error) for model 1, 2. Which model is closer to the real distribution?
  4. take 3 countries of your choice: one from Asia, one from Europe and one from the Middle East. For each of these countries do the following:

(a) compute F, P and π

(b) using RMSE as a ”distance” metric, for which of these chosen three countries is the distribution ”closest” to equal weight P?

  1. discuss your findings

Expert Solution

Archived Solution
Unlocked Solution

You have full access to this solution. To save a copy with all formatting and attachments, use the button below.

Already a member? Sign In
Important Note: This solution is from our archive and has been purchased by others. Submitting it as-is may trigger plagiarism detection. Use it for reference only.

For ready-to-submit work, please order a fresh solution below.

Or get 100% fresh solution
Get Custom Quote
Secure Payment