Message Boards Message Boards

0
|
4577 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Restoring ordered pairs?

Posted 7 years ago

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?

POSTED BY: Paige Myers
2 Replies
Posted 7 years ago

Thanks! It worked perfectly!

POSTED BY: Paige Myers

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 BY: Sander Huisman
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