0
$\begingroup$

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?

$\endgroup$

1 Answer 1

4
$\begingroup$

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?

$\endgroup$
3
  • $\begingroup$ @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. $\endgroup$
    – thils
    Commented May 1, 2013 at 21:13
  • 3
    $\begingroup$ 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. $\endgroup$
    – whuber
    Commented May 1, 2013 at 21:21
  • $\begingroup$ @whuber Yes, I am after statistical independence, apologies. "later manipulations" is for determining mean, median & performing error analysis on the extracted data lists. $\endgroup$
    – thils
    Commented May 1, 2013 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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