Question

Solve the following problem in juypter/python code and plot any results. Suppose that the values for...

Solve the following problem in juypter/python code and plot any results.


Suppose that the values for a given set of data are grouped into intervals. The intervals and corresponding
frequencies are as follows.


Age   frequency
1-5      200
5-15    450
15-20 300
20-50   1500
50-80   700
80-110 44
Compute an approximate median value of age for the data?


Output your Answer as answer.csv in the output directory:

Homework Answers

Answer #1

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

ageMin=[1,5,15,20,50,80,110] #interval is in pair, index 0,1 1,2 2,3 3,4 4,5 5,6 6,7
frequency=[200,450,300,1500,700,44]


L=0
#L is the lower class boundary of the group containing the median
if(len(frequency)%2==0):
L=ageMin[len(frequency)//2]
else:
L=ageMin[(len(frequency)//2)]

n=sum(frequency)#Total Number of Values
B=0
for i in range(0,ageMin.index(L)):
B=B+frequency[i]

#B is the cumulative frequency of the groups before the median group

G=frequency[ageMin.index(L)]
#G is the frequency of median group
w=ageMin[ageMin.index(L)+1]-ageMin[ageMin.index(L)]
#w is group width
print(L)
print(n)
print(B)
print(G)
print(w)
estimatedMedian=L-(((n/2)-B)/G)*w

print("Approximate median value of age for the data: "+str(estimatedMedian))

import csv
with open('output.csv', 'w', newline='') as file: #resource will be closed automatically
writer = csv.writer(file)
writer.writerow([estimatedMedian]) #writes an array of data to csv

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ONLY NEED OUTPUT VALUES FOR C AND D. PLUS FINAL PLOT Use the following code to...
ONLY NEED OUTPUT VALUES FOR C AND D. PLUS FINAL PLOT Use the following code to show that the power method can be used to calculate the largest eigenvalue and corresponding eigenvector of a covariance matrix. A. Generate the data: x <- rnorm(1000) dim(x) <- c(50,20) x <- x* 1:9 x[,1] <- x[,1]*2+ x[,3] + x[,20] x[,5] <- x[,5]*3+ x[,3] +2* x[,20] B.Calculate the covariance matrix and its powers vx <- var(x) vx2 <- vx%*%vx vx4 <- vx2%*%vx2 vx8 <-...
ONLY NEED VALUES FOR C AND D. PLUS FINAL PLOT Use the following code to show...
ONLY NEED VALUES FOR C AND D. PLUS FINAL PLOT Use the following code to show that the power method can be used to calculate the largest eigenvalue and corresponding eigenvector of a covariance matrix. A. Generate the data: x <- rnorm(100000) dim(x) <- c(500,200) x <- x* 1:9 x[,1] <- x[,1]*2+ x[,3] + x[,20] x[,5] <- x[,5]*3+ x[,3] +2* x[,20] B.Calculate the covariance matrix and its powers vx <- var(x) vx2 <- vx%*%vx vx4 <- vx2%*%vx2 vx8 <- vx4%*%vx4...
Use Python to Complete the following on a single text file and submit your code and...
Use Python to Complete the following on a single text file and submit your code and your output as separate documents. For each problem create the necessary list objects and write code to perform the following examples: Sum all the items in a list. Multiply all the items in a list. Get the largest number from a list. Get the smallest number from a list. Remove duplicates from a list. Check a list is empty or not. Clone or copy...
Data was collected for 364 randomly selected 10 minute intervals. For each ten-minute interval, the number...
Data was collected for 364 randomly selected 10 minute intervals. For each ten-minute interval, the number of people entering the atrium of a large mall were recorded. The data is summarized in the table below. Number   of Guests      Frequency    220 – 239 83 240 – 259 95 260 – 279 47 280 – 299 43 300 – 319 96 What is the class width for this GFDT? Class width = The number of students in the tutoring center was recorded...
Assume data coming from a price skimming experiment, where the price of a particular product was...
Assume data coming from a price skimming experiment, where the price of a particular product was reduced in an online platform over 17 consecutive days, in steps of $50 from an initial value of $1,000 to a final value of $200. The price was maintained constant during each day, and was changed at the beginning of the following day. The last column represents the total number of purchases observed during the corresponding day. b) Plot the empirical revenue function, for...
Part 2 (Numerical Descriptive Techniques) The following data represent the ages of a sample of 25...
Part 2 (Numerical Descriptive Techniques) The following data represent the ages of a sample of 25 employees from a government department. Enter this data on a sheet called Employee Data.       31        43        56        23        49        42        33        61        44        28       48        38        44        35        40        64        52        42        47        39       53        27        36        35        20 Find the median age. Find the lower quartile of the ages. Find the upper quartile of the ages. Compute the range and...
Coding in Python Add radio button options for filing status to the tax calculator program of...
Coding in Python Add radio button options for filing status to the tax calculator program of Project 1. The user selects one of these options to determine the tax rate. The Single option’s rate is 20%. The Married option is 15%. The Divorced option is 10%. The default option is Single. Be sure to use the field names provided in the comments in your starter code. ================== Project 1 code: # Initialize the constants TAX_RATE = 0.20 STANDARD_DEDUCTION = 10000.0...
Using the class sample data, analyze the student heights by completing the following. Please note the...
Using the class sample data, analyze the student heights by completing the following. Please note the following directions. The data below was collected from a group of 45 female students last semester. You will use this data throughout the semester on your lab assignments. Student # Gender Height Shoe Age Hand 1 F 68 8.5 20 R 2 F 60 5.5 27 R 3 F 64 7 31 R 4 F 67 7.5 19 R 5 F 65 8 20...
Let x be the age of a licensed driver in years. Let y be the percentage...
Let x be the age of a licensed driver in years. Let y be the percentage of all fatal accidents (for a given age) due to failure to yield the right of way. For example, the first data pair states that 5% of all fatal accidents of 37-year-olds are due to failure to yield the right of way. x 37 47 57 67 77 87 y 5 8 10 15 31 44 Complete parts (a) through (e), given Σx =...
clemson This Excel file Undergrad Survey shows the data resulting from a survey of 50 undergraduate...
clemson This Excel file Undergrad Survey shows the data resulting from a survey of 50 undergraduate students at Clemson University. Majors of students in the survey are accounting (A), economics and finance (EF), management (M), marketing (MR), computer information systems (IS), other (O), and undecided (UN). "Number of affiliations" is the number of social networking sites at which the student is registered; "Spending" is the amount spent on textbooks for the current semester. The other variables are self-explanatory. We will...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT