Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Section 1 : Preliminaries 1 a ) Simulating a Multinomial np . random. multinomial ( n , p _ array ) simulates n draws at

Section 1: Preliminaries
1a) Simulating a Multinomial
np. random. multinomial(n, p_array) simulates n draws at random with replacement from the categorical distribution p_array and returns an array of the
observed counts in all the categories.
You have seen a version of this in Data 8. The datascience function sample_proportions is just np. random. multinomial with the output converted to
proportions.
Run the cell below to draw 10 times from a population in which 20% are in Category A,70% in Category B, and 10% in Category C. The output array contains the
observed counts in Categories A, B, and C.
Confirm that it makes sense, by looking at the total count and the count in each category. Then run the cell a few times to see how the observations change.
num_draws =10
population_proportions =[0.2,0.7,0.1] # make_array (0.2,0.7,0.1) is also fine
np. randon.multinonial(num_draws, population_proportions)
array([2,7,1])
1b) Adding Rows to a Table
You know that t. with_columns can be used to add a column or columns to a table t. Sometimes it is useful to grow a table by adding rows. Start by creating the
table with just the column labels and no rows, as follows.
t=Table([' Column A', 'Column B', 'Colunn C'])
t
Column A Column B Column C
a temporary copy of t that you have to name if you want to save it. Run the two cells below and keep track of what happens to t.
t.append([1,2,3]
t has been changed
t
Column A Column B Column C
To append another row, use append again.
t.append ([4,5,6]
1c) Putting the Two Together
Create a table simulated_counts that has column labels A, B, and C. The table should have two rows. Each row should contain the observed counts in
Categories A, B, and C in 10 multinomial trials, each of which results in Category A with chance 0.2, Category B with chance 0.7, and Category C with chance 0.1 as in
Part a above. The trials in each row should be independent of those in the other row.
You should use no more than 3 lines of code.
Answer to 1c
...
a.
simulated_counts. Please help solve the last part
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago