The problem is known as the Josephus Problem (or Josephus permutation) and postulates a group of people of size N >= 1 are standing in a circle waiting to be eliminated. Counting begins at a specified point in the circle and proceeds around the circle in a specified direction. After a specified number of M >= 1 people are counted, the M^th person in the circle is eliminated. The procedure is repeated with the remaining people, starting with the next person, going in the same direction and counting the same number of people, until only one person remains.
For example, suppose that M = 3 and there are N = 5 people named A, B, C, D and E. We count three people starting at A, so that C is eliminated first. We then begin at D and count D, E and back to A, so that A is eliminated next. Then we count B, D and E, and finally B, D and B, so that D is the one who remains last.
For this computer assignment, you are to write and implement a C++ program to simulate and solve the Josephus problem. The input to the program is the number M and a list of N names, which is clockwise ordering of the circle, beginning with the person from whom the count is to start. After each removal, the program should print the names of all people in the circle until only one person remains. However, to save printing space, print the names of the remaining people only after K >= 1 eliminations, where K is also an input argument to the program. The input arguments N, M and K can be entered from stdin in the given order. (see josephus.d for values)
Programming Notes:
Name the people in the circle in the following sequence: A1, A2 ... A9, B1, B2 ... B9, C1, C2 ..., and start counting from the person A1. Enter input values N, M and K when the program prompts for them and use a list<string> container to store the names of N people.
void init_vals(list<string> &L, args &in) It reads the input values N, M and K of the struct args in when the program prompts for them. The routine prints out those values on stdout, and fills the names of people in the list L. You can find the definition of the struct args in the header file josephus.h, which is defined as:
struct args
{
unsigned N;
unsigned M;
unsigned K;
};
void print_list(const list<string> &L, const unsigned &cnt) It prints out the contents of the list L at the beginning and after removing K names (each time) from the list, until only one name remains in the list, where cnt has an initial value 0 and it indicates the total number of removals so far. At the end, it also prints the name of the last remaining person. For printout, print only up to 12 names in a single line, where the names are separated by single spaces.
The main() routine first calls the routine init_vals() and initializes cnt to 0, and then calls the print_list() to print out the names of people in circle. After that it locates the M^th person in the list, and using the member function erase(), it removes that person from the list, and by calling the print_list() prints out the current contents of the list. This process continues (in a loop) until only one person remains in the list.
If i (with initial value 0) indicates the position of a person in list L, then the statement: j = (i + (M –1))%L.size() returns the position of the M^th person from the position i.
Since the argument to the erase() function is an iterator, you can convert the index value j to an iterator by the advance(p, j) function, where p = L.begin().
To store the names in an empty list, first change the size of the list to N, and then use the generate() function in the STL. The last argument to this function is the function object SEQ(N), which is defined in the header file josephus.h.
Assignment Notes:
Include any necessary headers and add necessary global constants.
You are not allowed to use any I/O functions from the C library, such as scanf or printf. Instead, use the I/O functions from the C++ library, such as cin or cout.
In: Computer Science
The table below shows the critical reading scores for 14 students the first two times they took a standardized test. At α =0.01,
is there enough evidence to conclude that their scores improved the second time they took the test? Assume the samples are random and dependent, and the population is normally distributed. Complete parts (a) through (f).
|
Student |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Score on first test |
409 |
360 |
365 |
406 |
605 |
489 |
387 |
384 |
605 |
528 |
321 |
362 |
362 |
321 |
|
|
Score on second testScore on second test |
418 |
437 |
442 |
454 |
536 |
533 |
386 |
520 |
673 |
581 |
331 |
390 |
392 |
342 |
a) Identify the claim and state H0 and Ha.
The claim is "The students' critical reading test scores ▼ (decreased, did not change, changed, improved) the second time they took the test.
Let μd be the hypothesized mean of the the students' first score minus their second score. State H0 and Ha.
Choose the correct answer below.
A. H0: μ≥d
Ha: μ<d
B. H0: μ≤d
Ha: μ>d
C. H0: μ≥0
Ha: μ<0
D.
H0: μ≠0
Ha:μ=0
E. H0: μ≤0
Ha:μ>0
F. H0: μ=0
Ha: μ≠0
(b) Find the critical value(s) and identify the rejection region(s).
t 0= (Use a comma to separate answers as needed. Type an integer or a decimal. Round to three decimal places as needed.)
Identify the rejection region(s). Choose the correct answer below.
A. t<−2.650 or t>2.650
B. t<−2.650
C. t<−3.012 or t>3.012
D. t>3.012
(c) Calculate d and sd.
d= (Type an integer or a decimal. Round to three decimal places as needed.)
Calculate sd.
sd= Type an integer or a decimal. Round to three decimal places as needed.)
(d) Use the t-test to find the standardized test statistic t.
t= (Type an integer or a decimal. Round to three decimal places as needed.)
(e) Decide whether to reject or fail to reject the null hypothesis. Choose the correct answer below.
Fail to reject the null hypothesis.
Rejectthe null hypothesis.
(f) Interpret the decision in the context of the original claim. Choose the correct answer below.
A. At the 1% significance level, there is not enough evidence that the students' critical reading scores improved the second time they took the test.
B. At the 1% significance level, there is enough evidence that the students' critical reading scores improved the second time they took the test.
C. The sample was not large enough to make a conclusion.
D. At the 1% significance level, there is evidence that the students' critical reading scores got worse the second time they took the test
In: Statistics and Probability
What is the relationship between the amount of time statistics students study per week and their final exam scores? The results of the survey are shown below.
| Time | 16 | 13 | 9 | 14 | 14 | 16 | 0 | 6 |
|---|---|---|---|---|---|---|---|---|
| Score | 98 | 82 | 91 | 100 | 86 | 95 | 62 | 83 |
In: Statistics and Probability
The average GPA of a random sample of 18 college students who
take evening classes was calculated to be 2.94 with a standard
deviation of 0.04. The average GPA of a random sample of 12 college
students who take daytime classes was calculated to be 2.89 with a
standard deviation of 0.05. Test the claim that the mean GPA of
night students is larger than the mean GPA of day students at the
.01 significance level.
Claim: Select an answer μ 1 < μ 2 μ 1 ≤ μ 2 p 1 = p 2 p 1≠p 2 p
1 < p 2 p 1 > p 2 p 1 ≤ p 2 μ 1 = μ 2 p 1 ≥ p 2 μ 1 > μ 2
μ 1≠μ 2 μ 1 ≥ μ 2 which corresponds to Select an answer
H1: μ 1 < μ 2 H0: μ 1 = μ 2 H1: μ 1≠μ 2 H1: p 1≠p 2 H0: μ 1 ≤ μ
2 H1: p 1 > p 2 H1: μ 1 > μ 2 H0: p 1 ≤ p 2 H1: p 1 < p 2
H0: μ 1≠μ 2
Opposite: Select an answer p 1 < p 2 p 1 ≤ p 2 μ 1 ≥ μ 2 μ 1
< μ 2 μ 1 = μ 2 μ 1 > μ 2 μ 1 ≤ μ 2 p 1 ≥ p 2 p 1 > p 2 μ
1≠μ 2 p 1 = p 2 p 1≠p 2 which corresponds to Select an
answer H0: p 1≠p 2 H1: μ 1 > μ 2 H0: μ 1 ≤ μ 2 H1: μ 1≠μ 2 H1: p
1 ≥ p 2 H0: p 1 > p 2 H1: p 1 <= p 2 H1: p 1 = p 2 H0: μ 1 =
μ 2 H1: μ 1 < μ 2 H0: μ 1≠μ 2
The test is: Select an answer two-tailed right-tailed
left-tailed
The test statistic is: tt = Select an answer 2.9 2.415 2.546 3.007
3.181
The critical value is: tαtα= Select an
answer 2.384 2.453 2.718 2.919 2.563
Based on this we: Select an answer Cannot determine anything Accept
the null hypothesis Fail to reject the null hypothesis Reject the
null hypothesis
Conclusion There Select an answer does not
does appear to be enough evidence to support the claim
that the mean GPA of night students is larger than the mean GPA of
day students.
In: Statistics and Probability
Is it true that students tend to gain weight during their first year in college? Cornell Professor of Nutrition David Levitsky recruited students from two large sections of an introductory health course. Although they were volunteers, they appeared to match the rest of the freshman class in terms of demographic variables such as sex and ethnicity. The students were weighed during the first week of the semester, then again 12 weeks later at the end of the semester (weights are in pounds).
| subject | initial weight | terminal weight |
| 1 | 171 | 168 |
| 2 | 110 | 111 |
| 3 | 134 | 136 |
| 4 | 115 | 119 |
| 5 | 150 | 155 |
| 6 | 104 | 106 |
| 7 | 142 | 148 |
| 8 | 120 | 124 |
| 9 | 144 | 148 |
| 10 | 156 | 154 |
| 11 | 114 | 114 |
| 12 | 121 | 123 |
| 13 | 122 | 126 |
| 14 | 120 | 115 |
| 15 | 115 | 118 |
| 16 | 110 | 113 |
| 17 | 142 | 146 |
| 18 | 127 | 127 |
| 19 | 102 | 105 |
| 20 | 125 | 125 |
| 21 | 157 | 158 |
| 22 | 119 | 126 |
| 23 | 113 | 114 |
| 24 | 120 | 128 |
| 25 | 135 | 139 |
| 26 | 148 | 150 |
| 27 | 110 | 112 |
| 28 | 160 | 163 |
| 29 | 220 | 224 |
| 30 | 132 | 133 |
| 31 | 145 | 147 |
| 32 | 141 | 141 |
| 33 | 158 | 160 |
| 34 | 135 | 134 |
| 35 | 148 | 150 |
| 36 | 164 | 165 |
| 37 | 137 | 138 |
| 38 | 198 | 201 |
| 39 | 122 | 124 |
| 40 | 146 | 146 |
| 41 | 150 | 151 |
| 42 | 187 | 192 |
| 43 | 94 | 96 |
| 44 | 105 | 105 |
| 45 | 127 | 130 |
| 46 | 142 | 144 |
| 47 | 140 | 143 |
| 48 | 107 | 107 |
| 49 | 104 | 105 |
| 50 | 111 | 112 |
| 51 | 160 | 162 |
| 52 | 134 | 134 |
| 53 | 151 | 151 |
| 54 | 127 | 130 |
| 55 | 106 | 108 |
| 56 | 185 | 188 |
| 57 | 125 | 128 |
| 58 | 125 | 126 |
| 59 | 155 | 158 |
| 60 | 118 | 120 |
| 61 | 149 | 150 |
| 62 | 149 | 149 |
| 63 | 122 | 121 |
| 64 | 155 | 158 |
| 65 | 160 | 161 |
| 66 | 115 | 119 |
| 67 | 167 | 170 |
| 68 | 131 | 131 |
1) Construct a dotplot depicting the distribution of the change in the students’ weights from the beginning of the semester to the end of the semester.
2)Suppose Professor Levitsky wishes to use the data he collected from his students in a research paper. He wants to prove freshman students tend to gain weight during their first semester in college.
Frame this research question as a hypothesis testing problem. Identify the parameter being tested, the null value, and explicitly write out the null and alternative hypothesis in terms of the parameter and null value.
In: Statistics and Probability
1) Are unnecessary c-sections putting moms and babies health at risk? The procedure is a major surgery which increases risks for the baby (breathing problems and surgical injuries) and for the mother (infection, hemorrhaging, and risks to future pregnancies). According to the Center for disease control and prevention, about 32.2% of all babies born in the U.S. are born via c-section. The World Health Organization recommends that the US reduce this rate by 10%.
Some states have already been working towards this. Suspecting that certain states have lower rates than 32.2%, researchers randomly select 1200 babies from Wisconsin and find that 20.8% of the sampled babies were born via c-section.
Let p be the proportion of all babies in the U.S. that are born via c-section. Give the null and alternative hypotheses for this research question.
1) H0: p = .322
Ha: p < .322
2) H0: p = .322
Ha: p ≠ .322
3) H0: p = .208
Ha: p ≠ .208
4) H0: p < .322
Ha: p = .322
5) H0: p = .322
Ha: p > .322
2) A quality control engineer at a potato chip company tests the bag filling machine by weighing bags of potato chips. Not every bag contains exactly the same weight. But if more than 15% of bags are over-filled then they stop production to fix the machine.
They define over-filled to be more than 1 ounce above the weight on the package. The engineer weighs 100 bags and finds that 31 of them are over-filled.
He plans to test the hypotheses: H0: p = 0.15 versus Ha: p > 0.15 (where p is the true proportion of overfilled bags).
What is the test statistic?
1) 4.48
2) 3.46
3) -3.46
3) According to a Pew Research Center, in May 2011, 35% of all American adults had a smartphone (one which the user can use to read email and surf the Internet). A communications professor at a university believes this percentage is higher among community college students.
She selects 300 community college students at random and finds that 126 of them have a smartphone. In testing the hypotheses: H0: p = 0.35 versus Ha: p > 0.35, she calculates the test statistic as Z = 2.54.
Use the Normal Table to help answer the p-value part of this question.
1) There is enough evidence to show that more than 35% of community college students own a smartphone (P-value = 0.0055).
2) There is not enough evidence to show that more than 35% of community college students own a smartphone (P-value = 0.9945).
3) There is not enough evidence to show that more than 35% of community college students own a smartphone (P-value = 0.011).
4) There is not enough evidence to show that more than 35% of community college students own a smartphone (P-value = 0.0055).
In: Statistics and Probability
What is the relationship between the amount of time statistics students study per week and their test scores? The results of the survey are shown below. Time 2 5 9 1 4 11 13 11 13 Score 60 61 70 49 72 84 76 80 83 Find the correlation coefficient: r = Round to 2 decimal places. The null and alternative hypotheses for correlation are: H 0 : = 0 H 1 : ≠ 0 The p-value is: (Round to four decimal places) Use a level of significance of α = 0.05 to state the conclusion of the hypothesis test in the context of the study. There is statistically significant evidence to conclude that a student who spends more time studying will score higher on the test than a student who spends less time studying. There is statistically insignificant evidence to conclude that there is a correlation between the time spent studying and the score on the test. Thus, the use of the regression line is not appropriate. There is statistically insignificant evidence to conclude that a student who spends more time studying will score higher on the test than a student who spends less time studying. There is statistically significant evidence to conclude that there is a correlation between the time spent studying and the score on the test. Thus, the regression line is useful. r 2 = (Round to two decimal places) Interpret r 2 : There is a 78% chance that the regression line will be a good predictor for the test score based on the time spent studying. Given any group that spends a fixed amount of time studying per week, 78% of all of those students will receive the predicted score on the test. There is a large variation in the test scores that students receive, but if you only look at students who spend a fixed amount of time studying per week, this variation on average is reduced by 78%. 78% of all students will receive the average score on the test. The equation of the linear regression line is: ˆ y = + x (Please show your answers to two decimal places) Use the model to predict the test score for a student who spends 9 hours per week studying. Test score = (Please round your answer to the nearest whole number.) Interpret the slope of the regression line in the context of the question: For every additional hour per week students spend studying, they tend to score on average 2.22 higher on the test. The slope has no practical meaning since you cannot predict what any individual student will score on the test. As x goes up, y goes up. Interpret the y-intercept in the context of the question: The average test score is predicted to be 54. The best prediction for a student who doesn't study at all is that the student will score 54 on the test. If a student does not study at all, then that student will score 54 on the test. The y-intercept has no practical meaning for this study.
In: Statistics and Probability
Question 6 (1 point)
According to a survey of 786 small business participants chosen at random in the Constant Contact Small Biz Council in May of 2013, 431 of the respondents say it is harder to run a small business now than it was 5 years ago. When estimating the population proportion, what is the 90% confidence interval estimating the proportion of businesses who believe it is harder to run a business now than 5 years ago?
Question 6 options:
|
|||
|
|||
|
|||
|
|||
|
Question 7 (1 point)
A U.S. census bureau pollster noted that in 379 random households surveyed, 218 occupants owned their own home. What is the 99% confidence interval estimate of the proportion of American households who own their own home?
Question 7 options:
|
|||
|
|||
|
|||
|
|||
|
Question 8 (1 point)
You are watching a nightly news broadcast on CNN and the reporter says that a 90% confidence interval for the proportion of Americans who supported going to war in Iraq was ( 0.4073 , 0.4635 ). You also note that the footnote says this is based on a random sample performed by Gallup with 836 respondents. What is the correct interpretation of this confidence interval?
Question 8 options:
|
|||
|
|||
|
|||
|
|||
|
Question 9 (1 point)
Based on past data, the Student Recreation Center knew that the proportion of students who prefer exercising outside over exercising in a gym was 0.836. To update their records, the SRC conducted a survey. Out of 85 students surveyed, 71 indicated that they preferred outdoor exercise over exercising in a gym. The 99% confidence interval is ( 0.7317 , 0.9389 ). Which of the following statements is the best conclusion?
Question 9 options:
|
|||
|
|||
|
|||
|
|||
|
In: Statistics and Probability
4) A magazine reported the results of a survey in which readers were asked to send their responses to several questions regarding good eating. DataSet for question 4,5,6 is the reported results to the question, How often do you eat chocolate? Based on the data answer the following questions.
a) Were the responses to this survey obtained using voluntary sampling technique? Explain
b) What type of bias may be present in the response?
c) is 13% a reasonable estimate of the proportion of all Americans who eat chocolate frequently? Explain.
5) A magazine reported the results of a survey in which readers were asked to send in their responses to several questions regarding anger. DataSet2 for Question 5 shows the reported results to the question, How long do you usually stay angry? Answer the following questions based on the data.
a) Were the responses to this survey obtained using voluntary sampling technique?
b) What type of bias may be present in the response?
c) Is 22% a reasonable estimate of the proportion of all Americans who hold a grudge indefinitely? Explain.
6) Students in marketing class have been asked to conduct a survey to determine whether or not there is demand for an insurance program at a local college. The Students decided to randomly select students from the local college and mail them a questionnare regarding the insurance program. Of the 150 questionnaire that were mailed, 50 students responded to the following survey item: Pick the Category which best describes your interest in an insurance program. DataSet2 for question 6 shows the responses. Use this data to answer the following question.
a)What type of bias may be present in the response?
b) is 50% a reasonable estimate of the proportion of all students who would be very interested in an insurance program at a local college? Explain.
c) is 50% a reasonable estimate of the proportion of all business majors who would be very interested in an insurance program at a local college? Explain.
d) What strategies do you think the marketing students could have used in order to get a less biased response to their survey?
e) Suppose the program was created and only a few people registered. How could the survey question have been reworded to better predict the actual enrollment?
DATA SET FOR QUESTION 4, 5 AND 6
Table for Question 4 – Survey Responses
Category % of Responses
Frequently 13
Occasionally 45
Seldom 37
Never 5
Table for Question 5 – Survey Responses
Category % of Responses
A few hours or less 48
A day 12
Several days 9
A month 1
I hold a grudge indefinitely 22
It depends on the situation 8
Table for Question 6 – Survey Responses
Category % of Responses
Very Interested 50
Somewhat Interested 15
Interested 10
Not Very Interested 5
Not At All Interested 20
In: Math
Writing Assignment #1 Instructions
The following assignment should be typed and printed or handwritten
and turned in to the CA office in room 201 TMCB. If there is no
one in the CA Office, you can slip your assignment through the slot
in the door.
You must follow the instructions below or you will not receive
credit. You can turn in the assignment up until 5:00 PM on the due
date.
Important Notices: If you do not staple multiple pages, you may
lose points. If you do not put your section number on the paper,
you may lose points. As shown below, please fold your paper
lengthwise and on the outside write (a) your name, (b) Stat 121,
(c) your section number, and (d) the assignment number. (An example
is available outside the CA Office.)
The situation is as follows:
Rent and other associated housing costs, such as utilities, are an
important part of the estimated costs of attendance at college. A
group of researchers at the BYU Off-Campus Housing department want
to estimate the mean monthly rent that unmarried BYU students paid
during Winter 2019. During March 2019, they randomly sampled 366
BYU students and found that on average, students paid $348 for rent
with a standard deviation of $76. The plot of the sample data
showed no extreme skewness or outliers.
Calculate a 98% confidence interval estimate for the mean
monthly rent of all unmarried BYU students in Winter 2019.
STATE
What is a 98% confidence interval estimate for the mean monthly
rent of all unmarried BYU students in Winter 2019?
PLAN
1. State the name of the appropriate estimation procedure.
(2pts)
2. Describe the parameter of interest in the context of the
problem. (2pts)
SOLVE
1. Name the conditions for the procedure. (2pts)
2. Explain how the above conditions are met. (2pts)
3. Write down the confidence level and the t* critical value.
(2pts)
4. Calculate the margin of error for the interval to two decimal
places. Show your work. (2pts)
5. Calculate the confidence interval to two decimal places and
state it in interval form. (2pts)
CONCLUDE
Interpret your confidence interval in context. Do this by including
these three parts in your conclusion (3 pts):
● Level of confidence (1pt)
● Parameter of interest in context (1 pt)
● The interval estimate (1 pt)
FURTHER ANALYSIS
1. How would selecting a 95% level of confidence change the size of
the calculated confidence interval? (1pt). Explain or justify your
answer by recalculating (1pt) .
2. At a 95% level of confidence, what sample size would be
needed to estimate the parameter of interest to within a margin of
error of ± $25? Use σ = $76. (2pts)
3. Suppose that a second random sample of unmarried BYU students
was conducted during March 2019. Using this data, the confidence
interval was calculated to be ($342.67, $349.35). Rounded to two
decimal places, what is the margin of error for this confidence
interval? Show your work. (1pt)
In: Math