1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
solmaris [256]
3 years ago
15

Median of a sample If the distribution is given, as above, the median can be determined easily. In this problem we will learn ho

w to approximate the median when the distribution is not given, but we are given samples that it generates. Similar to distributions, we can define the median of a set to be the set element m′ such that at least half the elements in the set are ≤m′ and at least half the numbers in the collection are ≥m′. If two set elements satisfy this condition, then the median is their average. For example, the median of [3,2,5,5,2,4,1,5,4,4] is 4 and the median of [2,1,5,3,3,5,4,2,4,5] is 3.5. To find the median of a P distribution via access only to samples it generates, we obtain ???? samples from P, caluclate their median ????????, and then repeat the process many times and determine the average of all the medians.
Exercise 2

Write a function sample_median(n,P) that generates n random values using distribution P and returns the median of the collected sample.

Hint: Use function random.choice() to sample data from P and median() to find the median of the samples

* Sample run *

print(sample_median(10,[0.1 0.2 0.1 0.3 0.1 0.2]))
print(sample_median(10,[0.1 0.2 0.1 0.3 0.1 0.2]))
print(sample_median(5,P=[0.3,0.7])
print(sample_median(5,P=[0.3,0.7])
* Expected Output *

4.5
4.0
2.0
1.0
Exercise 4

In this exercise, we explore the relationship between the distribution median mm, the sample median with ????n samples, and ????[????????]E[Mn],the expected value of ????????Mn.

Write a function average_sample_median(n,P), that return the average ????????Mn of 1000 samples of size n sampled from the distribution P.

* Sample run *

print(average_sample_median(10,[0.2,0.1,0.15,0.15,0.2,0.2]))
print(average_sample_median(10,[0.3,0.4,0.3]))
print(average_sample_median(10,P=[0.99,0.01])
* Expected Output *

3.7855
2.004
1
----------------------------------------------------------------------

Question a:

In exercise 2,

Which of the following is a possible output of sample_median(n, [0.12,0.04,0.12,0.12,0.2,0.16,0.16,0.08]) for any n?

3

9

7

4

Question b:

In exercise 4,

what value does average_sample_median(100,[0.12, 0.04, 0.12, 0.12, 0.2, 0.16, 0.16, 0.08]) return?

Computers and Technology
1 answer:
kumpel [21]3 years ago
7 0

Answer:

def sample_median(n,P):

return np.median(np.random.choice(np.arange(1,len(P)+1),n,p=P))

Explanation:

See attached picture.

You might be interested in
To change the print orientation from portrait to landscape, tap or click the ____ button on the print preview tab.
lianna [129]
<span>In certain instances, it makes sense to print documents in landscape orientation. Some examples include spreadsheets and tables, where the content within the document is wider than it is longer. If you print in portrait mode, it would cut off parts of the table or spreadsheet. In this case, you'll want to change the print settings to landscape. To change it to landscape, simply click the "landscape" button on the print preview tab.</span>
4 0
3 years ago
Karen works in a department store. Her coworker gave diverse cultural backgrounds. Which statement shows that Karen understand t
Goshia [24]

Answer:

Karen!

Explanation:

hahhahahahhahaahhahahaahahha

she wouldn't understand anything

anyways, where is the statements THEN I'll edit my answer シ

5 0
3 years ago
A TV game show Jeopardy! contestant who uses a strategy to seek out the hidden Daily Double questions, which are usually the thr
jek_recluse [69]

Answer:

Game theory.

Explanation:

In the TV game show Jeopardy! Game theory allows contestant to use a strategy to seek out the hidden Daily Double questions, instead of the more common approach of selecting a single category and selecting questions gradually increasing in the degree of difficulty.

Game theory is the process of using mathematical model in the study of strategic interaction between two or more players in a game or situation having laid down rules and outcomes.

8 0
3 years ago
En cual programa puedo hacer un mapa mental
mojhsa [17]
Hay aplicaciones especializadas para la creación de mapas mentales . Pero la herramienta más simple podría ser un papel y algunas plumas . El segundo sencillo cuando no tiene instalado el software podría ser la creación de un mapa mental en MS Word
3 0
3 years ago
What are two ways the broad-match modifier makes Jamie's work easier? (Choose two.)
Mariana [72]

Answer:

1) She doesn’t have to think of all the related saucepan keywords

2) She can easily select the colour she wants to focus on.

Explanation:

Broad match modifiers ensure  ads will only show for searches that include the words you’ve marked with a plus sign, such as +blue +suede +shoes. Broad match modifiers can help your keywords reach a greater clickthrough rate (CTR) with a more targeted customer audience, which in turn can help your site get more paying customers or other conversions

4 0
4 years ago
Other questions:
  • The domain name is passed to a domain name server, which maps it to the correct IP address, and then the code behind the page is
    12·1 answer
  • Alice is adding a chart in a spreadsheet. Which option will allow you her to give the chart a suitable title and subtitle?
    11·2 answers
  • What is a GUI?
    11·1 answer
  • Do you need internet to play xbox one
    14·1 answer
  • Anyone understand coding? Please Help! Thank you! :)
    8·1 answer
  • Briefly explain what are JavaScript librairies​
    12·1 answer
  • A ? is the desired value where a process should be maintained. The value may be manually set, automatically set, or programmed.
    13·1 answer
  • IMPORTANT!!<br><br> How can you get real answer keys for edmentum (plato) courses as a student?
    11·1 answer
  • Write a program that implements a class called Dog that contains instance data that represent the dog's name and age. • define t
    10·1 answer
  • Select the correct answer from each drop-down menu.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!