A professor in the School of Business wants to investigate the prices of new textbooks in the campus bookstore and the Internet. The professor randomly chooses the required texts for 12 business school courses and compares the prices in the two stores. The results are as follows:
|
Book |
Campus Store |
Internet Price |
|
1 |
$55.00 |
$50.95 |
|
2 |
47.50 |
45.75 |
|
3 |
50.50 |
50.95 |
|
4 |
38.95 |
38.50 |
|
5 |
58.70 |
56.25 |
|
6 |
49.90 |
45.95 |
|
7 |
39.95 |
40.25 |
|
8 |
41.50 |
39.95 |
|
9 |
42.25 |
43.00 |
|
10 |
44.95 |
42.25 |
|
11 |
45.95 |
44.00 |
|
12 |
56.95 |
55.60 |
H1:
(2)
(3)
(4)
H1:
p-value:
(2)
(3)
(4)
In: Statistics and Probability
Please find implementation of KNN algorithm (in C++) below
Please explain how each code implements the following steps of the algorithm in question:
1. Determine parameter K = number of nearest neighbors
2. Calculate the distance between the query-instance and all the
training samples
3. Sort the distance and determine nearest neighbors based on the
K-th minimumdistance
4. Gather the category Y of the nearest neighbors
5. Use simple majority of the category of nearest neighbors as the
prediction value of the query instance
// C++ program to find groups of unknown
// Points using K nearest neighbour algorithm.
#include <bits/stdc++.h>
using namespace std;
struct Point
{
int val; // Group of point
double x, y; // Co-ordinate of point
double distance; // Distance from test point
};
// Used to sort an array of points by increasing
// order of distance
bool comparison(Point a, Point b)
{
return (a.distance < b.distance);
}
// This function finds classification of point p using
// k nearest neighbour algorithm. It assumes only two
// groups and returns 0 if p belongs to group 0, else
// 1 (belongs to group 1).
int classifyAPoint(Point arr[], int n, int k, Point p)
{
// Fill distances of all points from p
for (int i = 0; i < n; i++)
arr[i].distance =
sqrt((arr[i].x - p.x) * (arr[i].x - p.x) +
(arr[i].y - p.y) * (arr[i].y - p.y));
// Sort the Points by distance from p
sort(arr, arr+n, comparison);
// Now consider the first k elements and only
// two groups
int freq1 = 0; // Frequency of group 0
int freq2 = 0; // Frequency of group 1
for (int i = 0; i < k; i++)
{
if (arr[i].val == 0)
freq1++;
else if (arr[i].val == 1)
freq2++;
}
return (freq1 > freq2 ? 0 : 1);
}
// Driver code
int main()
{
int n = 17; // Number of data points
Point arr[n];
arr[0].x = 1;
arr[0].y = 12;
arr[0].val = 0;
arr[1].x = 2;
arr[1].y = 5;
arr[1].val = 0;
arr[2].x = 5;
arr[2].y = 3;
arr[2].val = 1;
arr[3].x = 3;
arr[3].y = 2;
arr[3].val = 1;
arr[4].x = 3;
arr[4].y = 6;
arr[4].val = 0;
arr[5].x = 1.5;
arr[5].y = 9;
arr[5].val = 1;
arr[6].x = 7;
arr[6].y = 2;
arr[6].val = 1;
arr[7].x = 6;
arr[7].y = 1;
arr[7].val = 1;
arr[8].x = 3.8;
arr[8].y = 3;
arr[8].val = 1;
arr[9].x = 3;
arr[9].y = 10;
arr[9].val = 0;
arr[10].x = 5.6;
arr[10].y = 4;
arr[10].val = 1;
arr[11].x = 4;
arr[11].y = 2;
arr[11].val = 1;
arr[12].x = 3.5;
arr[12].y = 8;
arr[12].val = 0;
arr[13].x = 2;
arr[13].y = 11;
arr[13].val = 0;
arr[14].x = 2;
arr[14].y = 5;
arr[14].val = 1;
arr[15].x = 2;
arr[15].y = 9;
arr[15].val = 0;
arr[16].x = 1;
arr[16].y = 7;
arr[16].val = 0;
/*Testing Point*/
Point p;
p.x = 2.5;
p.y = 7;
// Parameter to decide group of the testing point
int k = 3;
printf ("The value classified to unknown point"
" is %d.\n", classifyAPoint(arr, n, k, p));
return 0;
}
Output:
The value classified to unknown point is 0.
In: Computer Science
Red Canyon T-shirt Company operates a chain of T-shirt shops in the southwestern United States. The sales manager has provided a sales forecast for the coming year, along with the following information:
| Quarter 1 | Quarter 2 | Quarter 3 | Quarter 4 | ||||
| Budgeted Unit Sales | 31,000 | 51,000 | 25,500 | 51,000 | |||
|
|
|||||||
Each T-shirt is expected to sell for $21.
The purchasing manager buys the T-shirts for $8 each.
The company needs to have enough T-shirts on hand at the end of each quarter to fill 31 percent of the next quarter’s sales demand.
Selling and administrative expenses are budgeted at $62,000 per quarter plus 18 percent of total sales revenue.
Required:
1. Determine budgeted sales revenue for each quarter
|
2. Determine budgeted cost of merchandise
purchased for each quarter
|
3. Determine budgeted cost of good sold for each
quarter.
|
4. Determine selling and administrative expenses for each quarter.
|
5. Complete the budgeted income statement for each
quarter.
|
|||||||||||||||||||||||||||||||||||||||||||||||||
In: Accounting
Exercise 2:
You are provided with a text file named covid19-3.txt. It reports a
few confirmed cases of covid19. It consists of three columns. The
1st column indicates the names of the provinces, the 2nd column
indicates the names of the countries and the 3rd column indicates
the numbers of confirmed cases.
To do:
1. Define a function that reads, from covid19-3.txt, provinces,
countries and confirmed cases in three separate lists.
2. Define a function that iterates through a list (or array) from
the second element to the last and finds the smallest elements
between them.
3. Define a function that sorts confirmed cases from largest to
smallest. The sorted numbers must be returned by the function in a
list or an array. The function should also return the names of the
provinces in the order of confirmed cases.
Note:
1. You have to design your functions yourself, including input and
output parameters.
2. You need to manually check the preprogram result whether the
sorting (confirmed cases and also provinces) is done correctly or
not.
data::
Province,Country,Confirmed
Anhui,Mainland China,1
Beijing,Mainland China,14
Chongqing,Mainland China,6
Fujian,Mainland China,1
Gansu,Mainland China,0
Guangdong,Mainland China,26
Guangxi,Mainland China,2
Guizhou,Mainland China,1
Hainan,Mainland China,4
Hebei,Mainland China,1
Heilongjiang,Mainland China,0
Henan,Mainland China,5
Hong Kong,Hong Kong,0
Hubei,Mainland China,444
Hunan,Mainland China,4
Inner Mongolia,Mainland China,0
Jiangsu,Mainland China,1
Jiangxi,Mainland China,2
Jilin,Mainland China,0
Liaoning,Mainland China,2
Macau,Macau,1
Ningxia,Mainland China,1
Qinghai,Mainland China,0
Shaanxi,Mainland China,0
Shandong,Mainland China,2
Shanghai,Mainland China,9
Shanxi,Mainland China,1
Sichuan,Mainland China,5
Taiwan,Taiwan,1
Tianjin,Mainland China,4
Tibet,Mainland China,0
Washington,US,1
Xinjiang,Mainland China,0
Yunnan,Mainland China,1
Zhejiang,Mainland China,10
Xima,Japan,2
Mano,Thailand,2
Suool,South Korea,1
Anhui,Mainland China,9
Beijing,Mainland China,22
Chongqing,Mainland China,9
Fujian,Mainland China,5
Gansu,Mainland China,2
Guangdong,Mainland China,32
Guangxi,Mainland China,5
Guizhou,Mainland China,3
Hainan,Mainland China,5
Hebei,Mainland China,1
Heilongjiang,Mainland China,2
Henan,Mainland China,5
Hong Kong,Hong Kong,2
Hubei,Mainland China,444
Hunan,Mainland China,9
Inner Mongolia,Mainland China,0
Jiangsu,Mainland China,5
Jiangxi,Mainland China,7
Jilin,Mainland China,1
Liaoning,Mainland China,3
Macau,Macau,2
Ningxia,Mainland China,1
Qinghai,Mainland China,0
Shaanxi,Mainland China,3
Shandong,Mainland China,6
Shanghai,Mainland China,16
Shanxi,Mainland China,1
Sichuan,Mainland China,8
Taiwan,Taiwan,1
Tianjin,Mainland China,4
Tibet,Mainland China,0
Washington,US,1
Xinjiang,Mainland China,2
Yunnan,Mainland China,2
Zhejiang,Mainland China,27
In: Computer Science
Product M is made by processing materials in three sequential processes, 1, 2 and 3. The details of the process cost for the financial period 2 were as follows:
|
Process 1 |
Process 2 |
Process 3 |
|
|
K |
K |
K |
|
|
Direct material introduced (5000kg) |
40 000 |
||
|
Direct material added |
12 000 |
25 280 |
46 400 |
|
Direct labour |
10 000 |
12 000 |
20 000 |
|
Direct expenses |
8 000 |
12 400 |
8 160 |
Budgeted departmental overheads for period 2 were K168,000 and absorbed into the cost of each process on a percentage of Direct Labour Cost.
|
Output and normal loss data are as follows: |
|||
|
Process 1 |
Process 2 |
Process 3 |
|
|
Actual Output |
4 400 kg |
4 200 kg |
3 500 kg of |
|
product Simba |
|||
|
Normal loss |
10% |
5% |
10% |
Normal loss is a partially toxic material and is sold at K2, K6 and K10 in processes 1, 2 and 3 respectively.
There was no finished inventory at the beginning of the period and no work-in process at either the beginning or end of the period.
Required:
(a) Prepare process 1, 2 and 3 accounts
(b) Prepare abnormal losses and normal gain account showing balance to be transferred to the statement of comprehensive income account.
(c) Explain the distinction between a by-product and a joint product.
In: Accounting
We consider a monocentric city represented by a segment x 2 [0,xf ] where 0 stands for the CBD where everybody works and earns a uniform (exogenous) urban wage w >0 and xf is the city fringe. The rural wage a is normalized to zero. Agents located at a distance x from the CBD pay a rent R(x). The utility of an agent is her disposable income.
1 Fixed commuting cost
1.1 Private transportation
Agents drive to the CBD and incur a fixed commuting cost cc >0
per unit of distance.
1. Find the general formula for R(x) and xf .
2. What is the impact of each parameter of the model on these two
outcomes?
3. Graph the rent function if cc =4 and w =100.
1.2 A metro station
Public authorities build one metro station located at point m such
that 0 <m <xf . To go to the CBD, agents now either still
drive to the CBD or combine private driving to the metro station
and metro. Using the metro, the commuting cost per unit of distance
is cm <cc .
1. Find the general formula for R(x) and xf . What is the impact of
each parameter of the model on these two outcomes?
2. Graph the rent function if cc =4, cm =1, w =100 and m =20.
3. Let cc =4, cm =1, w =100 and m =50. Graph the rent function.
What is the particularity of the
city in this case?
4. Can you give examples of the previous case in real life?
5. Let cc =4, cm =1, w =100. What is the size of the largest
continuous city that can be achieved with only one metro station?
Graph the rent function.
6. In real life, why might urban planners want to create continuous
cities?
In: Economics
Use the geometric probability distribution to solve the
following problem.
On the leeward side of the island of Oahu, in a small village,
about 71% of the residents are of Hawaiian ancestry. Let n
= 1, 2, 3, … represent the number of people you must meet until you
encounter the first person of Hawaiian ancestry in the
village.
(a) Write out a formula for the probability distribution of the
random variable n. (Enter a mathematical
expression.)
P(n) =
(b) Compute the probabilities that n = 1, n =
2, and n = 3. (For each answer, enter a number. Round your
answers to three decimal places.)
P(1) =
P(2) =
P(3) =
(c) Compute the probability that n ≥ 4. Hint:
P(n ≥ 4) = 1 − P(n = 1) −
P(n = 2) − P(n = 3). (Enter a
number. Round your answer to three decimal places.)
(d)What is the expected number of residents in the village you
must meet before you encounter the first person of Hawaiian
ancestry? Hint: Use μ for the geometric
distribution and round. (Enter a number. Round your answer to the
nearest whole number.)
residents
In: Statistics and Probability
Assume that buyers are located along a line at points 1, 2 and 3. Each has a reservation price equal to 10. Marginal cost and average cost are equal to 4. There are 4 buyers located at points 1 and 3, and 2 buyers located at point 2. Seller A is located at point 1 and seller B is located at point 3. Transport cost is t = 1. When the price for both sellers is the same for a group of buyers, then half the buyers purchase from each seller. Only integer prices are allowed.
1. When both sellers charge price 10, then each will earn profit = _____.
a) 12
b) 24
c) 36
d) 8
e) 40
2. If seller A charges a price of 8 and seller B charges a price of 9, then the profit earned by seller A is _______.
a) 20
b) 32
c) 16
d) 24
e) 18
3. When seller A charges a price of 8, seller B's best response is to charge P = _____.
a) 9 or 10
b) 8 or 9
c) 6 or 7
d) 7 or 9
e) 5 or 6.
In: Economics
In: Finance
Use the geometric probability distribution to solve the
following problem.
On the leeward side of the island of Oahu, in a small village,
about 89% of the residents are of Hawaiian ancestry. Let n
= 1, 2, 3, … represent the number of people you must meet until you
encounter the first person of Hawaiian ancestry in the
village.
(a)
Write out a formula for the probability distribution of the
random variable n. (Enter a mathematical
expression.)
P(n) =
(b)
Compute the probabilities that n = 1, n = 2,
and n = 3. (For each answer, enter a number. Round your
answers to three decimal places.)
P(1) =
P(2) =
P(3) =
(c)
Compute the probability that n ≥
4. Hint: P(n ≥ 4) = 1 −
P(n = 1) − P(n = 2) −
P(n = 3). (Enter a number. Round your answer to
three decimal places.)
(d)
What is the expected number of residents in the village you must
meet before you encounter the first person of Hawaiian ancestry?
Hint: Use μ for the geometric distribution and
round. (Enter a number. Round your answer to the nearest whole
number.)
In: Statistics and Probability