Question

IN PYTHON: i have a list of integers: [15299, 35279, 179, 89, 129, 415, 179, 129,...

IN PYTHON:

i have a list of integers:

[15299, 35279, 179, 89, 129, 415, 179, 129, 819, 999, 175, 549, 3755, 899, 399, 159, 159, 290, 499, 4549, 849, 390, 498, 13299, 499, 199, 119, 149, 257, 2549, 189, 189, 60, 1749, 899, 226, 399, 189, 186, 1099, 899, 499, 89, 415, 499]

i want to make a histogram and calculate summary statistics (mean, median, standard deviation, inner-quartile range, minimum, maximum, and any outliers) on this list of data.

Homework Answers

Answer #1

Please find below the python code to calculating the statistics summary of the provided list along with the histogram

*Mean

*Median

*Mode

*Standard Deviation

*IQR(Inner Quartile Range)

We have used numpy module to calculate the needed statistics and matlabplot to draw the histogram. We have used formula to calculate the bin for the histogram plotting. Comments are provided along the code to help you understand better

Code

import numpy
import matplotlib.pyplot as plt
import math
from scipy import stats



list = [15299, 35279, 179, 89, 129, 415, 179, 129, 819, 999, 175, 549, 3755, 899, 399, 159, 159, 290, 499, 4549, 849, 390, 498, 13299, 499, 199, 119, 149, 257, 2549, 189, 189, 60, 1749, 899, 226, 399, 189, 186, 1099, 899, 499, 89, 415, 499]


#calculate the bin for histogram
length=len(list)
print("Length of the list is",length)
max_v=max(list)
print("max value in list is: ",max_v)
min_v=min(list)
print("min value in list is: ",min_v)
range_v=(max_v-min_v)
print("range in list is: ",range_v)
number=math.sqrt(length)
width=int(range_v/number)


#Calculating the statistics of the list
#Calculating the mean for the list
x=numpy.mean(list)
print("Mean for the list is : ",x)

#Calculating median for the list
y=numpy.median(list)
print("Median for the list is : ",y)

#Calculating mode for the list
z=stats.mode(list)
print("Mode for the list is : ",z)


#Calculating standard deviation for the list
st=numpy.std(list)
print("Standard Deviation for the list is : ",st)

#Calculating the InnerQuartile Range

sorted_list=sorted(list)
# First quartile (Q1) 
Q1 = numpy.median(sorted_list[:int(length/2)]) 
  
# Third quartile (Q3) 
Q3 = numpy.median(sorted_list[int(length/2):]) 
  
# Interquartile range (IQR) 
IQR = Q3 - Q1 
  
print("InnerQuartile Range is : ",IQR) 

#drawing the histogram for the list
print("Drawing histogram for the list....")
plt.title("Histogram Figure")
plt.hist(list, bins = width)
plt.show()

Output

Note: If you like my answer, please review with thumbsup

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
A loan made on March 14 is due September 13 of the following year. Find the...
A loan made on March 14 is due September 13 of the following year. Find the exact time for the loan in a​ non-leap year and a leap year. days. The exact time in a​ non-leap year is ? days The exact time in a leap year is ? days. Data Table Sequential Numbers for Dates of the Year Day of Month Jan. Feb. Mar. Apr. May June July Aug. Sept. Oct. Nov. Dec. 1 1 32 60 91 121...
I am making a game like Rock Paper Scissors called fire water stick where the rules...
I am making a game like Rock Paper Scissors called fire water stick where the rules are Stick beats Water by floating on top of it Water beats Fire by putting it out Fire beats Stick by burning it The TODOS are as follows: TODO 1: Declare the instance variables of the class. Instance variables are private variables that keep the state of the game. The recommended instance variables are: 1. 2. 3. 4. 5. 6. A variable, “rand” that...
Researchers in a 2015 study by Flannery et al. sought to estimate the effectiveness of the...
Researchers in a 2015 study by Flannery et al. sought to estimate the effectiveness of the seasonal influenza vaccine in preventing acute respiratory infection (ARI). A total of 507 subjects from Texas who showed symptoms of ARI were recruited for this study. The data provided show the result of each subject's test for influenza. Click to download the data in your preferred format.    CrunchIt!    CSV    Excel    JMP    Mac-Text    Minitab    PC-Text    R   ...
Use the Manufacturing database from “Excel Databases.xls” on Blackboard. Use Excel to develop a multiple regression...
Use the Manufacturing database from “Excel Databases.xls” on Blackboard. Use Excel to develop a multiple regression model to predict Cost of Materials by Number of Employees, New Capital Expenditures, Value Added by Manufacture, and End-of-Year Inventories. Locate the observed value that is in Industrial Group 12 and has 7 employees. Based on the model and the multiple regression output, what is the corresponding residual of this observation? Write your answer as a number, round to 2 decimal places. SIC Code...
Your firm works in construction and buys ASTM A325M8S bolts in very large numbers. You are...
Your firm works in construction and buys ASTM A325M8S bolts in very large numbers. You are interested in purchasing bolts from different suppliers and have obtained and tested samples of 200 bolts from three suppliers: Allnutt, Boltzman, Coachers.You have tested these in your new bolt testing machine, purchased after you had discovered your old bolt testing machine was performing erratically. (For the purposes of this question, you are safe to assume that the new machine works perfectly and that its...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT