f



Sorting into bins

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}];

0
6/15/2011 11:19:59 AM
comp.soft-sys.math.mathematica 28821 articles. 0 followers. Follow

1 Replies
230 Views

Similar Articles

[PageSpeed] 33

.... I wish to sort a list of {{x,y}...} values into uneven bins using 
the x values

Hi.  Not sure, but here's one general method.

A general function that divides you x values based on size.  (I'll use 
Log10, but you can use your function here.).

f[x_]:=Log10[x]//Floor

Some Random data of length 2,3,& 4
I suggest Sorting the list here as it makes the code later a little 
easier.

t=RandomInteger[{1,2000},{10,2}]//Sort;
t//MatrixForm
(18	592
49	1441
67	672
670	713
1318	1827
1417	1487
1437	586
1594	40
1600	1908
1786	1564
)

GatherBy[t,f[First[#]]&] 

{
{{18,592},{49,1441},{67,672}},
{{670,713}},
{{1318,1827},{1417,1487},{1437,586},{1594,40},{1600,1908},{1786,1564}}
}


As you see, the bins are based on digit lengths of 2, 3 or 4.
You'll have to think of your own function here.

= = = = = = = = = =
HTH  : >)
Dana DeLouis
$Version
8.0 for Mac OS X x86 (64-bit) (November 6, 2010)

On Jun 15, 7:19 am, Hugh Goyder <h.g.d.goy...@cranfield.ac.uk> 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}];



0
dana.del (86)
6/17/2011 4:07:10 AM
Reply:

Similar Artilces:

sorted or .sort() ?
My poor understanding is that the difference between `sorted(somelist, key=lambda x:...)` and `somelist.sort(lambda x,y...)` is that one returns a new list and the other sorts in-place. Does that mean that .sort() is more efficient and should be favored when you can (i.e. when you don't mind changing the listish object)? Peter Bengtsson <peterbe@gmail.com> writes: > My poor understanding is that the difference between `sorted(somelist, > key=lambda x:...)` and `somelist.sort(lambda x,y...)` is that one > returns a new list and the other sorts in-place. Yes. > Does th...

Sorting out sort
I'm trying to extract a column from a flatfile database and print it alphabetically. I can get the data out, but I can't get it to sort. The database is pipe-separated in a plain text file and looks like this: Ref_no|Title|County|Another_field|And_another|And_another 1234|A Name|Devon|Data here|More data here|And more data 1234|A Name|Somerset|Data here|More data here|And more data 1234|A Name|Nottinghamshire|Data here|More data here|And more data 1234|A Name|Essex|Data here|More data here|And more data .... and so on My routine is as follows: #open the file open (INFILE, 'dat...

~bin and ~/bin ??
Hi All, Quick query on something i dont understand!!! there are many echo ~ /home/myprod/myprod echo ~/bin /home/myprod/myprod/bin Which I am okay with and totaly understand but why does echo ~bin give /usr/bin I dont understand how the shell interperets ~bin??? Boab <google@robertbrewer.co.uk> wrote: > Which I am okay with and totaly understand but why does > > echo ~bin > give > /usr/bin > > I dont understand how the shell interperets ~bin??? You forgot to say which shell you are using. Your shell expands ~bin to the home directory of the user 'bin&#...

math =!= mathematica
Does somebody know why I get different behaviour for the following commands in a commandline session of mathematica 7 or inside a notebook? It also seems to be different in different Mathematica versions for the notebook format. See http://www.risc.jku.at/people/hemmecke/mathematica/ for the notebook files for Mathematica 5.2, 6.0, 7.0. Can someone explain the General::dupsym: The symbol Array with context A` already exists. message? Why does that message appear at all? If A`Array exists, then Mathematica should just use it, shouldn't it? According to http://reference.wol...

Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2)
Assuming one needs to have a function returning false or true on each call in pseudo-random order.and using JavaScript native Math.random() method as the basis of the pseudo-randomness. Say the variants of such function are: getAnswer1() { var n = Math.round(Math.random()); return n ? true : false; } getAnswer2() { var n = Math.floor(Math.random()*2); return (n==2) ? true : false; } Leaving obvious practical testing by platforms aside: Is there are theoretical considerations that pseudo-randomness (predictability) of either of above will be better or worse than the o...

Integer math sort
Here is a version of the math (distribution) sort for sorting integers. Comments and suggestions for improvement are always welcome. It is about three times as fast as qsort out of the box. /* * Copyright (c) 2004 by Richard Harter. * This software may be freely used and modified without * restriction provided that this notice is preserved unaltered. * */ /* * This function sorts an array of integers in place using a math * sort based histogram sort. 2*len locations of auxilliary space * are used, where len is the data length. */ #include <stdlib.h> #define MIN_SORTABL...

Mathematica at Math Camp
I taught a group of 32 smart high school kids some Mathematica this week, at the Vermont Governor's Institute in Mathematical Sciences, aka Math Camp. This is my second year doing it, and it's a ton of fun. I had the kids an hour a day in one of our computer equipped classrooms, and this year we added some additional optional computer time in the late afternoons so they could come back and continue working / playing around. (Last year some of them wanted more time, but there was no time in the schedule when they could come back.) You might enjoy looking at graphs and a...

Learning maths with mathematica
Hi, I am going to fulfil a lifelong dream and will embark on a long distance physics university course in autumn after spending most of my working life as a professional musician in the abstract world of music. For this endeavour I have to brush up and recover my long lost maths basics. After discovering and trying out Mathematica I have purchased the home version of this amazing program which, after spending some time with it, I consider to be the swiss knife of everything. I would like to ask for recommendations about what would be the best way to use the program...

Re: math =!= mathematica
On 3/23/10 at 4:23 AM, hemmecke@gmail.com (hemmecke) wrote: >Does somebody know why I get different behaviour for the following >General::dupsym: The symbol Array with context A` already exists. >message? Why does that message appear at all? If A`Array exists, >then Mathematica should just use it, shouldn't it? >According to >http://reference.wolfram.com/mathematica/tutorial/Contexts.html we >have: >`name a symbol in the current context >So why is Mathematica complaining? The message is not telling you the symbol exists in the current cont...

/bin and /usr/bin?
Dear all, I found out /bin and /usr/bin contain the same command binaries such as "ls" and "rm". Is there any reason why the both directories contain the same(?) command files? or are the commands different? Can't we just use link instead? cheers, AK On 2008-07-12, Alexander Dong Back Kim <alexdbkim@gmail.com> expressed: > Dear all, > > I found out /bin and /usr/bin contain the same command binaries such > as "ls" and "rm". > Is there any reason why the both directories contain the same(?) > command files? or are the comman...

Mathematica Sorting Anti-Stable?
Consider: In[97]:= sortTestPoints = {{1, 1}, {1, 2}, {2, 1}, {2, 2}} Out[97]= (1 1 1 2 2 1 2 2 ) To produce a lexical sort, first sort by the second element. Notice it reverses the order of the first element (first clue that "Sort" might be antistable) In[99]:= Sort[sortTestPoints, #1[[2]] < #2[[2]] &] Out[99]= (2 1 1 1 2 2 1 2 ) Now, sort by the first element In[100]:= Sort[Sort[sortTestPoints, #1[[2]] < #2[[2]] &], #1[[1]] < #2 [[1]] &] Out[100]= (1 2 1 1 2 2 2 1 ) But, by itself, without a value for the the optio...

Sub-sort after sort
Hello, I have been sorting a list of dicts using the following function: result_rs = sorted(unsort_rs, key=itemgetter(orderby)) and this works fine. Now I am looking to perform a subsort as well. For example, I have this: test = [{'name': 'John Smith', 'location': 'CA',},{'name': 'John Smith', 'location': 'AZ',},] I would want to sort by name first, then sub sort by location. Any ideas? Thanks! On Nov 2, 2:45 pm, kee...@gmail.com wrote: > Hello, I have been sorting a list of dicts using the following > function: > &...

math typesetting, Mathematica, MathML
wrote a blog about linear algebra, math typesetting, and Mathematica export, that might be of interest to lispers. http://xahlee.blogspot.com/2010/11/linear-algebar-math-typesetting-and.html ------------------------- Here's a linear algebra notes i wrote in 1998, using Mathematica version 3, with much math typesetting. linearAlgebraNotes.nb =E3=80=94 http://xahlee.org/cmaci/notation/linearAlgebraNotes.nb =E3=80=95 .. Mathematica 7 convert it to pdf very well. See: linearAlgebraNotes.pdf =E3=80=94 http://xahlee.org/cmaci/notation/linearAlgebraNotes.pdf =E3=80=95 .. Surpris...

sort cmd
Having problems with sort (ver. 5.93 on SUSE 10.1). I have a 1.5 GB file which I sort with: sort -t ' ' -k 6 --output=sorted.txt data.txt This runs for a few minutes and gives me a file where things is sorted in sets, like aa aa bb bb bb cc dd dd ss xx bb bb cc cc cc dd ss ss Not what I expected, hoping to get the entire file sorted as one and not have a file with several sets which is sorted. Any ideas, what am I doing wrong? Thanks, Claus On Thu, 11 Jan 2007 06:01:51 -0800, nesalc wrote for every to trash: > Having problems with sort (ver. 5.93 on SUSE 10.1). > > I ...

Web resources about - Sorting into bins - comp.soft-sys.math.mathematica

Sorting - Wikipedia, the free encyclopedia
For sorting we can either specify a weak order "should not come after" or a strict weak order "should come before" (specifying one defines also ...

Category:WikiProject Stub sorting - Wikipedia, the free encyclopedia
This is a collection of policy pages, discussion pages and categories relevant to the WikiProject Stub sorting . They are in no way "owned" or ...

Sorting Through The Facebook IPO-Related Rumors
There’s no shortage of speculation and rumors about Facebook’s upcoming initial public offering , some of it plausible, some of it not so much. ...

Caboose Express: Patterns and Sorting for Preschool and Kindergarten on the App Store on iTunes
Get Caboose Express: Patterns and Sorting for Preschool and Kindergarten on the App Store. See screenshots and ratings, and read customer reviews. ...

David Gandy outside Oliver Spencer show, London Collections: Men SS 2014, Day 2, 17 June 2013, Old Sorting ...
David Gandy outside Oliver Spencer show, London Collections: Men SS 2014, Day 2, 17 June 2013, Old Sorting ...

Skittles Sorting Machine 2 - YouTube
This is a machine I designed to sort Skittles. It uses a BASIC Stamp 2 and 3 servos for actuation. An IR LED and phototransistor are used to ...

Gallop should take a run at sorting out Waratahs
Gallop should take a run at sorting out Waratahs

Hurricane Sandy - she's sorting the men from the boys
Hurricane Sandy - she's sorting the men from the boys

Blacksocks - Sock Sorting App - There's an app for that
Having problems sorting socks? There's an app for that

Convicts and sex slaves: sorting the fact from the fiction in British TV series 'Banished'
A salacious story about the establishment of Sydney's penal colony should not be mistaken for history.

Resources last updated: 2/2/2016 9:21:13 PM