Re: Correlating binary variables

• To: mathgroup at smc.vnet.net
• Subject: [mg70311] Re: Correlating binary variables
• From: "Philpp" <piotr at bigpond.net.au>
• Date: Thu, 12 Oct 2006 05:37:53 -0400 (EDT)
• References: <egi17o\$j42\$1@smc.vnet.net>

```Mickey,

Although the numbers you've given are consisting of 0s and 1s, they are
interpreted as decimal integers by Mathematica. You need to "force"
them to be interpreted as binary and convert them to their decimal
representation before doing regression.

In[1]:=  Map[FromDigits[IntegerDigits[#, 10], 2] &, {10101000101010010,
1010010100101001, 01010010100100101}]
Out[1]=  {86354, 107817, 42277}

or

In[2]:=  Clear[f];
f[binaryAsdecimal_Integer] :=
FromDigits[IntegerDigits[binaryAsdecimal, 10], 2];
Map[f, {10101000101010010, 11010010100101001,
01010010100100101}]
Out[4]=  {86354, 107817, 42277}

For comparison

In[5]:=  {2^^10101000101010010, 2^^11010010100101001,
2^^01010010100100101}
Out[5]=  {86354, 107817, 42277}

Cheers,
Phil.

mickey wrote:

> Hi,
>
> I have a problem where I am trying to find the correlation between a
> series of binary variables.
>
> 10101000101010010
> 11010010100101001
> 01010010100100101
>