Question

In: Computer Science

Given the names of employees in an office: employees = ["Jack", "Michael", "Tally", "John", "Jane", "Bill"]...

Given the names of employees in an office: employees = ["Jack", "Michael", "Tally", "John", "Jane", "Bill"]

1. Using the Random library in Python, create a codes that: Draws a random sample (with replacement) of 4 employees. Save and Displays the sample.

2. Explain what the difference is between a sample with replacement vs without replacement

Solutions

Expert Solution

Answer :-

2. difference between a sample with replacement vs without replacement

Sampling with replacement :
Sampling with replacement is a method of sampling where an item may be sampled more than once.

Sampling with replacement generally produces independent events.

When we sample with replacement, the two sample values are independent. Practically, this means that what we get on the first one doesn't affect what we get on the second.

Mathematically, this means that the covariance between the two is zero.

example:- For given question sample may be ["Jack" , "John" , "John" , "Bill"] (In with replacement Here employee name john will repeat)

Sampling with out replament :
Sampling with out replacement is a method of sampling where an item may not be sampled more than once.

sampling without replacement generally produces dependent events.

In sampling without replacement, the two sample values aren't independent. Practically, this means that what we got on the for the first one affects what we can get for the second one.

Mathematically, this means that the covariance between the two isn't zero.

example:- For given question sample may be ["Jack" , "John" , "Jane" , "Bill"] (In with out replacement Here employee name will not repeat)

1. Using the Random library in Python, create a codes that: Draws a random sample (with replacement) of 4 employees. Save and Displays the sample.

Answer :-

Python code :-

import random

employees = ["Jack", "Michael", "Tally", "John", "Jane", "Bill"] # given array

sample=[] # declare sample array

# Random sampling with replacement: random.choices() and k is number of employees
sample = random.choices(employees, k=4)

print(sample) # print sample

Screenshot of code and output :-


Related Solutions

Given the names of employees in an office: employees = ["Matthew", "Anna", "Curtis", "Jane", "Yang", "Tammie"]...
Given the names of employees in an office: employees = ["Matthew", "Anna", "Curtis", "Jane", "Yang", "Tammie"] Using the Random library in Python, create two codes that: A. Draws a random sample (without replacement) of 2 employees. Saves and displays the sample. B: Draws a random sample (with replacement) of 4 employees. Save and Displays the sample
Jane and John work as Medical Assistants in a physician’s office that still uses paper records....
Jane and John work as Medical Assistants in a physician’s office that still uses paper records. They discuss some of the benefits that converting to an EHR system would provide for practice management. They make a list of 5 benefits for converting to an electronic health record system. What might have been included on their list?
You are given a list of all employees. You group the names by department (Logistics, Sales,...
You are given a list of all employees. You group the names by department (Logistics, Sales, IT, Human Resource). Suppose you select all employees in Sales. What type of sampling method did you use to select the employees? Explain your reasoning.
2. Given the following sentences: 1. Jack owns Fiat 2. John owns Opel. 3. Fiat is...
2. Given the following sentences: 1. Jack owns Fiat 2. John owns Opel. 3. Fiat is a car and Opel is a car too. 4. Every car owner can drive 5. Jack exceeds the speed limit 6. John fasten seat belt. 7. Every driver who exceeds the speed limit or does not fasten seat belt breaks traffic rules. 8. Every one who can drive is a driver 9. Everyone who breaks any traffic rules will get a fine 10. Bad...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT