Re: Sorting into bins
- To: mathgroup at smc.vnet.net
- Subject: [mg119642] Re: Sorting into bins
- From: Heike Gramberg <heike.gramberg at gmail.com>
- Date: Thu, 16 Jun 2011 03:58:52 -0400 (EDT)
- References: <201106151120.HAA22812@smc.vnet.net>
If I understand your question correctly, you want to partition yy in sets such that the corresponding frequencies x of the elements in the i-th set are such that bb[[i-1]]<=x<bb[[i]]. One way of doing this is to do something like MapThread[Pick[yy, xx, a_ /; #1 <= a < #2] &, {ArrayPad[bb, {1, -1}], bb}] Heike. On 15 Jun 2011, at 12:20, Hugh Goyder wrote: > I wish to sort a list of {{x,y}...} values into uneven bins using the > x values to locate the bin but have the bins contain the y values. > This seems like an application for BinLists but it only seems to work > on a list of x values. The motivation is to give a spectra in terms of > 1/3 octaves which is a standard presentation in acoustics. Below I > construct the bin center frequencies cf, the bin boundaries bb and > generate a time history th, spectra, yy and corresponding frequencies > xx. How do I then sort the list into my bins? > > Thanks > Hugh Goyder > > cf = Table[(1/100.) Round[100 (1000/1024) 2^n], {n, 1, 15, 1/3}]; > bb = Table[Sqrt[cc[[i]]*cc[[i + 1]]], {i, 1, Length[cc] - 1}]; > sr = 60000.; > th = Table[y, {y, 0, 1, 1/sr}]; n = Length[th]; > yy = Take[ > Fourier[th, FourierParameters -> {1, -1}], {1, Ceiling[n/2]}]; > xx = Table[f, {f, 0, sr/2, sr/n}]; > data = Transpose[{xx, yy}]; >
- References:
- Sorting into bins
- From: Hugh Goyder <h.g.d.goyder@cranfield.ac.uk>
- Sorting into bins