Message Boards Message Boards

GROUPS:

Restoring ordered pairs?

Posted 1 year ago
1804 Views
|
2 Replies
|
1 Total Likes
|

Hey guys, I have a quick little question. So I'm analyzing some neural data on Mathematica in the form {time, amplitude}. Then I cluster based only on amplitude, so I end up with a series of amplitudes in a nested list like {{...........},{......},{...................},{.....................}}. I'm wondering, how do I restore the time to the amplitude it was originally paired with while maintaining its position according to the clustering function?

2 Replies

Hi Paige,

You can use GatherBy to gather them like so:

time = DateRange[{2017, 1, 1}, {2017, 12, 31}, 5];
amplitude = RandomInteger[5, Length[time]];
data = Transpose[{time, amplitude}];
GatherBy[data, Last]

If you used FindClusters, specify your data like this:

FindClusters[{a1->{t1,a1}, a2->{t2,a2}, a3->{t3,a3} .....}]
Posted 1 year ago

Thanks! It worked perfectly!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract