HW9-solutions
.html
keyboard_arrow_up
School
University of Texas *
*We aren’t endorsed by this school
Course
230
Subject
Statistics
Date
Apr 3, 2024
Type
html
Pages
8
Uploaded by sjobs3121
Homework 9 for ISEN 355 (System Simulation)
¶
(C) 2023 David Eckman
Due Date: Upload to Canvas by 9:00pm (CDT) on Monday, April 10.
In [ ]:
# Import some useful Python packages.
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats
Problem 1. (10 points)
¶
(a) (2 points)
Recall the linear congruential generator (LCG) introduced in Lecture 11.
Write a function that takes as input parameters $m$, $a$, and $c$ and a current value
$X_n$ and returns the next random number in the sequence, $X_{n+1}$.
In Python, the ``%'' symbol acts as the modulus operator. See Section 6.6 of the Python documentation
.
In [ ]:
# Example of modulus with % symbol.
# 5 mod 3 = 2
5 % 3
Out[ ]:
2
In [ ]:
def myLCG(current_x, m, a, c):
next_x = (a * current_x + c) % m return next_x
(b) (5 points)
As we did in the LCG example in lecture, set $m=32$, $a=11$, and $c=0$. An LCG with $m=32$ has the potential
to generate numbers in the set $\{0, 1,
2, \ldots, 30, 31\}$, but as we saw in class, for this choice of $a$ and $c$, the period is
less than 32.
For a fixed seed, e.g., $X_0 = 1$, recursively run your algorithm until the sequence of returned numbers repeats. Take turns trying different seeds until you have discovered all cycles
of numbers. List all cycles. (Note: Each number between 0 and 31 should appear exactly once in your list of cycles.)
In [ ]:
m = 32
a = 11
c = 0
ListOfCycles = []
repeat = set()
for seed in range(m):
period = 0
if seed in repeat:
continue # If we've seen this number already, skip it.
CurrentCycle = []
current_x = seed
while current_x not in repeat:
repeat.add(current_x)
period = period + 1
CurrentCycle.append(current_x)
current_x=myLCG(current_x, m, a, c)
ListOfCycles.append(CurrentCycle)
print(f"The cycle {CurrentCycle} has a period of {period}.")
The cycle [0] has a period of 1.
The cycle [1, 11, 25, 19, 17, 27, 9, 3] has a period of 8.
The cycle [2, 22, 18, 6] has a period of 4.
The cycle [4, 12] has a period of 2.
The cycle [5, 23, 29, 31, 21, 7, 13, 15] has a period of 8.
The cycle [8, 24] has a period of 2.
The cycle [10, 14, 26, 30] has a period of 4.
The cycle [16] has a period of 1.
The cycle [20, 28] has a period of 2.
(c) (3 points)
Repeat part (b) with the values $m=32$, $a=13$, and $c=3$. What is the period of the generator for these choices of parameters?
In [ ]:
m = 32
a = 13
c = 3
ListOfCycles = []
repeat = set()
for seed in range(m):
period = 0
if seed in repeat:
continue # If we've seen this number already, skip it.
CurrentCycle = []
current_x = seed
while current_x not in repeat:
repeat.add(current_x)
period = period + 1
CurrentCycle.append(current_x)
current_x = myLCG(current_x, m, a, c)
ListOfCycles.append(CurrentCycle)
print(f"The cycle {CurrentCycle} has a period of {period}.")
The cycle [0, 3, 10, 5, 4, 23, 14, 25, 8, 11, 18, 13, 12, 31, 22, 1, 16, 19, 26, 21, 20, 7, 30, 9, 24, 27, 2, 29, 28, 15, 6, 17] has a period of 32.
Problem 2. (5 points)
¶
For your simulation model of ETB, how many random numbers do you expect you might need to simulate one day of activity in the building? You may assume that for each random variate needed by your simulation, it can be transformed from one Uniform(0, 1) random variate. Explain in detail how you arrived at your answer.
A simulation model of ETB would need to generate random numbers for the interarrival
times of students, the schedules of students, the attendance of students to the classes, among other things. Using the data we have, we can obtain the expected number of individuals entering ETB each day; call this quantity X. To generate the arrival times of the X students, we would need at least X random numbers. (If using inversion to generate arrivals from a NSPP, which we didn't discuss in class, this would be true. If using thinning, the number of random numbers needed would depend on the peak of the arrival rate function, because we generate arrivals at the fastest rate.) For these X students, we might need to generate their daily class schedules, which would feature a random number of classes (likely less than or equal to 4) and random selections of classes. As an upper bound, we might need as many as 5X random numbers: 5 for each student (1 to generate a number 1-4 and then that many of numbers to pick the classes). We also need random numbers to handle the choice of which entrance to use ( 1X), taking the elevators or stairs (upper bounded by 1X), and
how long to spend studying (upper bounded by 3X, assuming no one has more than 3 study periods in a day). If the system is more complicated, more variates might be needed, such as for the activities of non-students (e.g., whether they take an elevator, to which floor they go, how long they spend in the building). From the analysis above, we might be looking at around 11X random numbers. If X is around 1500, for example,
we might need about 16500 random numbers to simulate one day of operations in ETB. Answers will vary greatly depending on what level of detail you intend to have in your Simio model.
Problem 3. (12 points)
¶
(a) (3 points)
Print the first 5 Uniform[0, 1] random variates generated by scipy.stats.uniform.rvs
when the underlying pseudo-random number generator is seeded with initial state 1234. Read the documentation of the scipy.stats.uniform
class
and the random_state
argument
to see how the size
and random_state
arguments should be set.
In [ ]:
random_variates = scipy.stats.uniform.rvs(size=5, random_state=1234)
print(f"The first 5 random variates are: {random_variates}.")
The first 5 random variates are: [0.19151945 0.62210877 0.43772774 0.78535858 0.77997581].
(b) (4 points)
With the generator again seeded at state 1234, generate 10,000 Uniform[0, 1] random variates and plot a histogram of their values using 100 bins. Comment on the shape of the histogram.
In [ ]:
random_variates = scipy.stats.uniform.rvs(size=10000, random_state=1234)
plt.hist(random_variates, bins=100)
plt.xlabel(r"Random Variate ($U$)")
plt.ylabel("Frequency")
plt.title("Histogram of 10,000 Uniform[0, 1] RVs")
plt.show()
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Hello, I'm not sure on how to go about solving questions 6, 7, and 8. Thanks in advance for your help.
arrow_forward
>
D2L Grades - N ✓
zy Section 6.2 ×
Google Le
Answered: ✓
Answered: ✓
Answered
✓
C chegg.com x
Homewor ✓
+
|
↓
C
learn.zybooks.com/zybook/MAT-240-Q4983-OL-TRAD-UG.24EW4/chapter/6/section/2
Relaunch to update :
G. Dashboard | ISN Horizon
ADP ADP
Home
Central Florida Per...
Math Review: Multi-...
K5 Grade 5 Reading Co...
◆ Orange County Pub...
OCPS Dashboard
Login
New Tab
All Bookmarks
= zyBooks My library > MAT 240: Applied Statistics home > 6.2: Confidence intervals for population means
| zyBooks catalog
? Help/FAQ Alnisha Liranzo
B
62°F
Clear
Challenge activities
CHALLENGE
ACTIVITY
6.2.1: Confidence intervals for population means.
554752.4160034.qx3zqy7
Jump to level 1
Suppose the mean height in inches of all 9th grade students at one high school is
estimated. The population standard deviation is 6 inches. The heights of 10
randomly selected students are 65, 67, 72, 75, 75, 62, 74, 67, 70 and 75.
x = Ex: 12.34
Margin of error at 99% confidence level =
=
Ex: 1.23
99% confidence…
arrow_forward
BAYBA
JOOH Baybay City
MATHEMATICS 7
ASSESSMENT for Module 3
2olubo
Section:
Name:
Contact No.:
Address:
Perform the indicated operations
1. |-5 |=
11. -9 – (-5) =
2. | +6 | =
etu 12. 9– 5 =
Vogoevi 13. 9- (-5) =
vhegoditeblb
3. |- 3 |=
4. |-1 + 4| =
o14. (-6)(+9) = nt
5. |7-9 |=
15. (+8)( –7) =
6. - 4 +7 =
16. (-9)(–9) =
Totsuaull 0x-
ego9 17. (+7)(+7) =
vhegor9 eeevn.b
7. - 4 + (-7) =
8.4+7 =
18.36 + 6 =
hagong nevip
9.4+(-7) =
19. 21 + (-7) =
10.-9-5=
20. -100 + (-5) =
Shot on realme C2
By Marla Cadayona
arrow_forward
QUESTION 2
Jim wants to buy a computer. The total cost is $1,180. If he can save $60 a month, how long will it take for him to save up for the computer?
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac).
BIUS
Paragraph
Arial
14px
!!
arrow_forward
Data
arrow_forward
Dashboard h ShoofVod - ia D C++ Shell 6 Microsoft
I Semester 2021
English (en) -
If (ak + be) = and
k-1
n
(ar-br) =
then a
ak =
k-1
n+2
k-1
2
O None
2
arrow_forward
YilIINVDQ6UM7xYVhdk%252Fakdvt9EeOsE8%252Fy11NyBX11f68q%252FbhZaws
prtals
Home-Canva
Apex Learning-Co..
E Portfolio: Ornar Per..
! My
Simplify
2i - 7i + 10
91+10
-51+10
arrow_forward
Do N X
Launch Meeting - Zoon X
A 3rd hour Dejah Soliloq x
Dejah Nix-Wade - Time X
ment/d/1Dg8RGQY37KuUse TafCzrxUWU63LDswgiHc2w-R404lc/edit
20 O
Add-ons Help
Last edit was 3 minutes ago
BIU
三===三
Arial
14
+
3
4.
Do Now
1. Rogers is 5 feet tall and casts a shadow 3.5 feet long. At the same time,
the flagpole outside his school cast a shadow 14 feet long. Write and solve
a proportional to find the height of the flagpole.
2. A small tree is 18 feet tall and casts a shadow 20 feet long. At the same
time, another large tree cast a shadow 42 feet long. Write and solve a
proportional to find the height of the large tree.
!!I
II
arrow_forward
+
: 9) O
a docs.google.com/document/d/1b1JBafNuORXUBc0xJb7Zvl90ixBLRbe-nkcdy706tPo/edit
8 ESL Galaxy
Q Quizlet o0 Duolingo G iready
A Classes
O Zooniverse
Algebra Calculator.
C Cymath
Desmos | Graphing.
Dashboard | Khan..
G Bet
Lissade Zachary - GU5L5 Exploration G A
TURN IN
File Edit View Insert Format Tools Add-ons Help
Last edit was 1 hour ago
Normal text
Arial
11
%00L
+
X 四四,出, 無世
2
Name:
Class:
Date:
Directions: Complete 5 out of 6 questions. Must show all work and include units !!!
Find the volume of the prisms and cylinders. ( Use n = 3.14)
pk 9
arrow_forward
I need help with 1 and 2.
arrow_forward
I don;t even know where to begin with this question
arrow_forward
Number 4
arrow_forward
O List of all commands - Photomd
O Math Expert Dashboard
M Inbox (13) - sharmadeepesh886
Dashboard
Training
Payments
Algebra / Teaching Skills
Teaching Skills Test
Important
Do not close tab or window while solving the quiz. Your answers will not be saved.
Question 3
Find all a, b, c ER that satisfy both equations:
a + 6+c= 63
ab + bc + ac = 2021
Previous
arrow_forward
cant understand a single thing that is written
arrow_forward
Write the standard for y=x+6
arrow_forward
A professor in a university is trying to conduct a research study. His study is trying to determine if his 8 am lecture is more interactive with him than his 2 pm lecture.
What is the confound?
How could this confound be fixed?
arrow_forward
can i please get the answer to this
arrow_forward
Explain why A and -A always have the same reduced echelon form R.
arrow_forward
se two systems fail
arrow_forward
(PROBLEM NO. 2) The sum of three integers is 55. The second integer is 8
less than the first and the third is 3 more than twice the first. What are the
numbers?
1. What is being asked in the problem? *
To find the second integer which is less than 8.
To find three numbers which sum is 55.
To find the third integer.
To find the first integer.
2. How will you represent the unknown data? *
Let x be the first integer, x-8 be the second integer, and 2x+3 be the third integer.
Let 2x be the first integer, 2x-8 be the second integer, and 2x+3 be the third integer.
Let x be the first integer, 8-x be the second integer, and 3x+2 be the third integer.
Let 2x be the first integer, 8-2x be the second integer, and 3x+2 be the third integer.
Ps
(?
IN
arrow_forward
Write Boolean expressions to describe the following multiple output circuits.
X1
x2
X3
>
У1
Y₂
arrow_forward
Consider the following Diagram, which represents all vegetables. O represents vegetables that are orange and Y represents vegetables that are
yellow.
Describe the vegetables in the following regions: r1, r2, and r3. Write you answers in complete sentences.
Vegetables
Y
13 r4
For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac).
A v
...
BIU S
14px
Paragraph
Arial
!!!
arrow_forward
Dashboard
082YUV80- MATH
didentity
app.teachermade.com/fill/a08bb518-cb48-4957-bda3-6d2a3a248b59
OC Q Q
T) I 14
Later
Submit
Independent Word Problems (y=mx+b)
1. You are visiting Baltimore, MD and a taxi company charges a flat fee of $3.00 for using the tax
$0.75 per mile.
A. Write an equation that you could use to find the cost of the taxi ride in Baltimore, MD.
represent the number of miles and y represent the total cost.
B. How much would a taxi ride for 8 miles cost?
C. If a taxi ride cost $15, how many miles did the taxi travel?
A
B
C
arrow_forward
2.
x+5x+6 x- 4x-21
X-1
x-1
arrow_forward
السؤال الأول
6.
Find the domain of y = Vx + 4x² + 5x + 2 +
Option 1 O
arrow_forward
Annotate x
A Saugus High School -Gale Pa x
6 Download Document
ZB2PJcRU2JydPgk/edit#slide=id.gc4cfaff04a_0_49
eppard Software..
ki Kahoot!
Social Studies Tech.
X XtraMath
O The World Factboo.
>>
nt Review ☆ D O
dit was 18 minutes ago
D Present
2 Share
10
+
BIUA
三 三
E - E E
2.
es - Solve for x.
M
(2x + 30
65
28
US I 8:52
Sign out
arrow_forward
Please help
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:9781133382119
Author:Swokowski
Publisher:Cengage
Algebra for College Students
Algebra
ISBN:9781285195780
Author:Jerome E. Kaufmann, Karen L. Schwitters
Publisher:Cengage Learning
Elementary Geometry for College Students
Geometry
ISBN:9781285195698
Author:Daniel C. Alexander, Geralyn M. Koeberlein
Publisher:Cengage Learning
Mathematics For Machine Technology
Advanced Math
ISBN:9781337798310
Author:Peterson, John.
Publisher:Cengage Learning,
Algebra: Structure And Method, Book 1
Algebra
ISBN:9780395977224
Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. Cole
Publisher:McDougal Littell
Related Questions
- Hello, I'm not sure on how to go about solving questions 6, 7, and 8. Thanks in advance for your help.arrow_forward> D2L Grades - N ✓ zy Section 6.2 × Google Le Answered: ✓ Answered: ✓ Answered ✓ C chegg.com x Homewor ✓ + | ↓ C learn.zybooks.com/zybook/MAT-240-Q4983-OL-TRAD-UG.24EW4/chapter/6/section/2 Relaunch to update : G. Dashboard | ISN Horizon ADP ADP Home Central Florida Per... Math Review: Multi-... K5 Grade 5 Reading Co... ◆ Orange County Pub... OCPS Dashboard Login New Tab All Bookmarks = zyBooks My library > MAT 240: Applied Statistics home > 6.2: Confidence intervals for population means | zyBooks catalog ? Help/FAQ Alnisha Liranzo B 62°F Clear Challenge activities CHALLENGE ACTIVITY 6.2.1: Confidence intervals for population means. 554752.4160034.qx3zqy7 Jump to level 1 Suppose the mean height in inches of all 9th grade students at one high school is estimated. The population standard deviation is 6 inches. The heights of 10 randomly selected students are 65, 67, 72, 75, 75, 62, 74, 67, 70 and 75. x = Ex: 12.34 Margin of error at 99% confidence level = = Ex: 1.23 99% confidence…arrow_forwardBAYBA JOOH Baybay City MATHEMATICS 7 ASSESSMENT for Module 3 2olubo Section: Name: Contact No.: Address: Perform the indicated operations 1. |-5 |= 11. -9 – (-5) = 2. | +6 | = etu 12. 9– 5 = Vogoevi 13. 9- (-5) = vhegoditeblb 3. |- 3 |= 4. |-1 + 4| = o14. (-6)(+9) = nt 5. |7-9 |= 15. (+8)( –7) = 6. - 4 +7 = 16. (-9)(–9) = Totsuaull 0x- ego9 17. (+7)(+7) = vhegor9 eeevn.b 7. - 4 + (-7) = 8.4+7 = 18.36 + 6 = hagong nevip 9.4+(-7) = 19. 21 + (-7) = 10.-9-5= 20. -100 + (-5) = Shot on realme C2 By Marla Cadayonaarrow_forward
- QUESTION 2 Jim wants to buy a computer. The total cost is $1,180. If he can save $60 a month, how long will it take for him to save up for the computer? For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). BIUS Paragraph Arial 14px !!arrow_forwardDataarrow_forwardDashboard h ShoofVod - ia D C++ Shell 6 Microsoft I Semester 2021 English (en) - If (ak + be) = and k-1 n (ar-br) = then a ak = k-1 n+2 k-1 2 O None 2arrow_forward
- YilIINVDQ6UM7xYVhdk%252Fakdvt9EeOsE8%252Fy11NyBX11f68q%252FbhZaws prtals Home-Canva Apex Learning-Co.. E Portfolio: Ornar Per.. ! My Simplify 2i - 7i + 10 91+10 -51+10arrow_forwardDo N X Launch Meeting - Zoon X A 3rd hour Dejah Soliloq x Dejah Nix-Wade - Time X ment/d/1Dg8RGQY37KuUse TafCzrxUWU63LDswgiHc2w-R404lc/edit 20 O Add-ons Help Last edit was 3 minutes ago BIU 三===三 Arial 14 + 3 4. Do Now 1. Rogers is 5 feet tall and casts a shadow 3.5 feet long. At the same time, the flagpole outside his school cast a shadow 14 feet long. Write and solve a proportional to find the height of the flagpole. 2. A small tree is 18 feet tall and casts a shadow 20 feet long. At the same time, another large tree cast a shadow 42 feet long. Write and solve a proportional to find the height of the large tree. !!I IIarrow_forward+ : 9) O a docs.google.com/document/d/1b1JBafNuORXUBc0xJb7Zvl90ixBLRbe-nkcdy706tPo/edit 8 ESL Galaxy Q Quizlet o0 Duolingo G iready A Classes O Zooniverse Algebra Calculator. C Cymath Desmos | Graphing. Dashboard | Khan.. G Bet Lissade Zachary - GU5L5 Exploration G A TURN IN File Edit View Insert Format Tools Add-ons Help Last edit was 1 hour ago Normal text Arial 11 %00L + X 四四,出, 無世 2 Name: Class: Date: Directions: Complete 5 out of 6 questions. Must show all work and include units !!! Find the volume of the prisms and cylinders. ( Use n = 3.14) pk 9arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Algebra & Trigonometry with Analytic GeometryAlgebraISBN:9781133382119Author:SwokowskiPublisher:CengageAlgebra for College StudentsAlgebraISBN:9781285195780Author:Jerome E. Kaufmann, Karen L. SchwittersPublisher:Cengage LearningElementary Geometry for College StudentsGeometryISBN:9781285195698Author:Daniel C. Alexander, Geralyn M. KoeberleinPublisher:Cengage Learning
- Mathematics For Machine TechnologyAdvanced MathISBN:9781337798310Author:Peterson, John.Publisher:Cengage Learning,Algebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal Littell
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:9781133382119
Author:Swokowski
Publisher:Cengage
Algebra for College Students
Algebra
ISBN:9781285195780
Author:Jerome E. Kaufmann, Karen L. Schwitters
Publisher:Cengage Learning
Elementary Geometry for College Students
Geometry
ISBN:9781285195698
Author:Daniel C. Alexander, Geralyn M. Koeberlein
Publisher:Cengage Learning
Mathematics For Machine Technology
Advanced Math
ISBN:9781337798310
Author:Peterson, John.
Publisher:Cengage Learning,
Algebra: Structure And Method, Book 1
Algebra
ISBN:9780395977224
Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. Cole
Publisher:McDougal Littell