4.8
4.9
4.7

# Create a function called histogram that takes as input a

Create a function called histogram that takes as input a dataset data, a lower bound b, an upper bound h, and a number of bins n, and returns a histogram representation of data with n bins between these bounds. More specifically, your function should:

Have input arguments histogram(data, n, b, h), expecting data as a list of floats, n as an integer, and b and h as floats.
Print the error message b and h are the same value and return an empty list if b and h are the same number (the width of the histogram is 0)
If b is larger than h, re-assign b to h and h to b.
If n is equal to 0, return an empty list
Initialize the histogram hist as a list of n zeros.
Calculate the bin width as w = (h-b)/n, so that hist[0] will represent values in the range (b, b + w), hist[1] in the range [b + w, b + 2w), and so on through hist[n-1]. (Remember that [ is inclusive while ) is not!).
Ignore any values in data that are less than or equal to b and greater than or equal to h. *Remember if you have changed h and b in step 3, you would need to work with the new value of h and b .
Increment hist[i] by 1 for each value in data that belongs to bin i, i.e., in the range [b + i*w, b + (i+1)*w).
Return hist.

At the beginning of your function, be sure to check that n is a positive integer; if not, your code should just return an empty list for hist. Please remember to return an empty list.
For example, typing in
data = [-2, -2.2, 0, 5.6, 8.3, 10.1, 30, 4.4, 1.9, -3.3, 9, 8] hist = histogram(data, 15, -5, 10) print(hist)
should return
[0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 2, 1]
Some other test cases are:
data = [-4, -3.2, 0, 7.6, 1.0, 2.2, 30, 2.2, 1.9, -8.3, 6, 5] hist = histogram(data, 10, 10, 0) print(hist)
should return
[0, 2, 2, 0, 0, 1, 1, 1, 0, 0]
and,
data = [2,2,2] hist = histogram(data, 5, -2, 3) print(hist)
returns
[0, 0, 0, 0, 3]
also,
data = [-1,-1,-1,10,10] hist = histogram(data, 5, -1, 10) print(hist)
returns
[0, 0, 0, 0, 0]
Note: Please include all conditions specified in this problem into your code.
Welcome to one of the bestassignmenthelpcompanies online .
Do you want to order for a customized assignment help task?
Click on the order now button
Set up your topic, Fix the number of pages, Fix your Order instructions
We delivery high quality and non plagiarized tasks within the stipulated time given

## Ordering Homework Writing Service

You can get our ideal online homework help services with four easy steps. All you have to do is inform us of your requirements. Immediately we will match with a specialist in your academic discipline. After that, we will track your order, review it to ensure it meets your requirements, and submit it to your email.

#### Submit Requirements

Fill in your assignment instructions on the order form

#### Quality review

We have a team of editors, who will thoroughly review your assignment, ensuring there are no errors before submission

### Affordable

Budget-friendly writing services

### Privacy

We don’t share our client’s information with a third party

### Unique

We write every assignment from scratch

## Amazing Homework Writing Features

Once you consult us for homework help online services, you will attest to why we are among the USA's best essay writing services.

Read on and find out some of the features that make our services superlative.

## Free Homework Writing Services

#### Free plagiarism checker

You can confirm that the content you get is original for free using our plagiarism checker.

#### Free title page and bibliography

Once you place an order, we format it accordingly without demanding additional charges.

#### Free unlimited revisions

We offer free unlimited revisions until your assignment is of your desired quality..