MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Map function with 2 variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114951] Re: Map function with 2 variables
  • From: Roland Franzius <roland.franzius at uos.de>
  • Date: Fri, 24 Dec 2010 04:10:37 -0500 (EST)
  • References: <iev2ua$4v6$1@smc.vnet.net>

Am 23.12.2010 09:57, schrieb Jagra:
> I have a problem that comes up in a couple of situations and I've
> never found the right solution.  I hoped I could get an idea of how to
> generally address these kinds of things.
>
> Say I have a function with two variables, something like a
> SpearmanRankCorrelation[] from the MultiVariate Statistics package:
>
> I also have matrix "m" with dimensions {3, 100}
>
> m = RandomReal[{0, 1}, {3, 100}];
>
> Now, say I want to create a correlation matrix using the
> SpearmanRankCorrelation function.
>
> I can get the rank correlations between a single vector of the matrix
> and all the other vectors like this:
>
> SpearmanRankCorrelation[m[[1]], #]&  /@ m
>
> This would give me a single row in a correlation matrix.   Pretty
> straightforward, but now I want all 3 rows like I would get with this:
>
> {SpearmanRankCorrelation[m[[1]], #]&  /@ m,
> SpearmanRankCorrelation[m[[2]], #]&  /@ m,
> SpearmanRankCorrelation[m[[3]], #]&  /@ m}
>
> There must be a way I can do this more directly.
> I must be missing something simple.

Two possibilities to generate product arrays from a given one:

Array[SpearmanRankCorrelation[m[[#1]], m[[#2]]] &, Length[m] {1, 1}]

Outer[SpearmanRankCorrelation, m, m, 1]

-- 

Roland Franzius



  • Prev by Date: Re: Map function with 2 variables
  • Next by Date: Re: Mathematica daily WTF
  • Previous by thread: Re: Map function with 2 variables
  • Next by thread: Re: Map function with 2 variables