Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Suppose I have the list with elements (either 1 or 4 as the last digit) as follows:

data=
{{42, 49.11, 1}, {41, 49.32, 4}, {41, 48.21, 4}, {41, 53.08, 1}, {39, 
  46.22, 1}, {39, 47.06, 1}, {47, 48.87, 4}, {41, 49.64, 1}, {41, 
  48.44, 1}, {42, 49.98, 4}, {39, 49.04, 1}, {46, 48.73, 1}, {49, 
  48.33, 4}, {39, 50.95, 1}, {42, 46.05, 4}, {49, 52.52, 1}, {49, 
  48.81, 1}, {49, 50.75, 4}, {47, 52.39, 1}, {41, 52.56, 1}, {40, 
  56.01, 4}, {46, 52.77, 4}, {43, 52.81, 1}, {39, 50.37, 1}, {40, 
  52.38, 1}, {49, 51.31, 4}, {48, 54.26, 4}, {40, 53.3, 4}, {42, 
  50.62, 4}, {48, 49.66, 4}, {43, 51.39, 4}, {41, 59.23, 4}, {41, 
  49.07, 4}, {40, 51.43, 4}, {39, 54.47, 4}, {49, 50.4, 4}, {48, 
  51.04, 1}, {46, 47.95, 1}, {45, 50.52, 4}, {44, 53.18, 1}}

How do I break it into two sets with the same last digit, such that

data1={{42, 49.11, 1},  {41, 53.08, 1}, {39, 
  46.22, 1}, {39, 47.06, 1}, {41, 49.64, 1}, {41, 
  48.44, 1}, {39, 49.04, 1}, {46, 48.73, 1}, {39, 50.95, 1}, 
 {49, 52.52, 1}, {49, 48.81, 1}...}

and

data2={{41, 49.32, 4}, {41, 48.21, 4}, {47, 48.87, 4},{42, 49.98, 4}, {49, 
  48.33, 4},  {42, 46.05, 4}, {49, 50.75, 4},  {40,   56.01, 4}, {46, 52.77, 4}..}

How do I test whether these two data sets are linearly independent?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

The first part is just:

GatherBy[data, Last]

For easy manipulation you might use this:

ruleData= #[[1, -1]] -> # & /@ GatherBy[data, Last];

Then get the part you want with e.g.:

4 /. ruleData
{{41, 49.32, 4}, {41, 48.21, 4}, {47, 48.87, 4}, . . .}

You'll have to explain in more detail what you mean by:

How do I test whether these two data sets are linearly independent?

share|improve this answer
    
@Wizard GatherBy command does not break up the list into 2 distinct lists, which will be convenient for later manipulations. By independence, I mean possibility of Pearson Correlation Tests etc. –  thils May 1 '13 at 21:13
3  
thils, it now sounds like you mean statistical independence, not linear independence. The two are entirely different things! Also, if you want something "convenient for later manipulations," you really ought to specify what procedures you have in mind--please don't make us guess. Edit your question to clarify what you need. –  whuber May 1 '13 at 21:21
    
@whuber Yes, I am after statistical independence, apologies. "later manipulations" is for determining mean, median & performing error analysis on the extracted data lists. –  thils May 1 '13 at 23:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.