Generate a vector to manipulate in the following exercises by using a random num
ID: 3798770 • Letter: G
Question
Generate a vector to manipulate in the following exercises by using a random number generator to ate "pull-ups" counts for 50 people. The counts should be from 1 to 10. Use this vector of counts for the next two problems. How many people did more than 5 pull-ups? Do your results make sense for a uniformly distributed random number generator? Generate another vector for "pull-ups" counts 50 athletes, so this time use the range from 11 to 20. Append this new vector to the previous vector (now you have 100 "pull-ups" counts). Find the average number of "pull-ups" for the 100 total people. Do your results make sense? Use the 100 person vector in c and create a new vector that contains only the counts from the odd-numbered indices (not the odd value counts, instead the counts for every other person starting with person 1). Use the 100 person vector in c and make a new vector of the "even-valued counts".Explanation / Answer
SCRIPT:
pullUpCount =randi([1,10],1,50); %answer a
aboveFive = sum(pullUpCount>5);
printf(" # of person with more than 5 pull-ups is %d",aboveFive); %answer b
pullUpCount =[pullUpCount, randi([11,20],1,50)]; %answer c
average = mean(pullUpCount);
printf(" Average of 100 persons is %f ",average); %answer d
oddCount = pullUpCount(1, 1:2:100); %answer e
evenCount= pullUpCount(1, 2:2:100); %answer f
OUTPUT:
# of person with more than 5 pull-ups is 24
Average of 100 persons is 10.450000
From the answer, we get expected results that we should expect from uniformly distributed data
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.