Python Forum
spread values of dataset equally over fixed number of bins
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
spread values of dataset equally over fixed number of bins
#1
Hi all,

I used numpy to bin some data with following simple code:
a = np.array(data)
histo = np.histogram(a,bins=nbrbins)
But the results look like this (left = bin, right = number of samples)
0.0->11356
5.7143->68
11.4286->18
17.1429->8
22.8572->3
28.5715->2
34.2858->1
40.0001->1
45.7144->6
51.4287->3

I would like to have all values more spread, so that the 0.0-5.7 bin would be split into smaller bins.
Which approach are you guys taking here? Should I look into other statistical packages?
In fact I would need bins that vary in size, but I still need the same number of bins. As far as I see, this couldn't be done with numpy.

Rgds,
M.
Reply
#2
You have many options for the 'bins' argument. They are described in the docstring of numpy.histogram()
Reply
#3
yes indeed, but none of the options worked. I want to have a fixed number of bins , and that's the problem. The options change the number of bins.
Reply
#4
You can set the bins option to an array of the bin edges, and have whatever bins you want.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Seaborn not displaying the specified n bins russellm10 0 567 Jun-28-2023, 02:51 AM
Last Post: russellm10
  How to copy a .csv worksheet into a .xlsx file without the number values turning into YoshikageKira 7 3,543 Mar-28-2020, 10:38 AM
Last Post: buran
  How to match number of features of training dataset to testing input anhnguyen 0 1,835 Feb-05-2020, 08:28 PM
Last Post: anhnguyen
  Join Predicted values with test dataset bhuwan 4 10,387 Mar-28-2019, 12:42 AM
Last Post: bhuwan
  How many unique values of quality are in this dataset? Jack_Sparrow 1 3,121 May-20-2018, 01:59 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020