Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Operation on specific cases' topicStudent Support Forum > General > Archives > "Operation on specific cases"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
yehuda
02/25/13 11:37pm

It is more than a simple Case or Select (since then you will have to loop according to the values of the first element)
1. Transpose a (Thread also works) so you get a list of pairs, one from the first list and one form the second list
2. GroupBy to group these pairs according to their first element
3. Use Map at level 2 to remove the first element
4 Map the function Mean on the result so you get your results

Mean /@ Map[Last, GatherBy[Transpose[a], First], {2}]


result is {3,4} as expected

HTH
yehuda

URL: ,

Subject (listing for 'Operation on specific cases')
Author Date Posted
Operation on specific cases Amin 02/25/13 3:08pm
Re: Operation on specific cases yehuda 02/25/13 11:37pm
Re: Operation on specific cases Bill Simpson 02/26/13 00:26am
Re: Re: Operation on specific cases yehuda 02/27/13 02:12am
Re: Re: Re: Operation on specific cases Amin 02/28/13 4:53pm
Re: Re: Re: Re: Operation on specific cases yehuda 02/28/13 10:51pm
Re: Operation on specific cases Amin 03/01/13 10:33pm
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic