[Tutor] Fwd: How to roughly associate the values of two numpy arrays, or python lists if necessary

Oscar Benjamin oscar.j.benjamin at gmail.com
Thu Sep 20 19:01:54 EDT 2018


Sydney wrote and Alan forwarded:

>
> I have, I suspect, an elementary problem that I am too inexperienced to
> resolve.
>
> I have two numpy arrays, each representing the values of a specific
> property of a set of cells.
>
> Now, I want to associate the two values for each cell, that is for each
> index of the numpy array. But I want to associate them ROUGHLY, that
> means, APPROXIMATELY, so that there is a weak, linear correlation
> between the values representing one property and the values representing
> the second property of each individual cell.
>
> Up to now I have used the following procedure.
> I have divided each population of values into four segments based on the
> value of the standard deviation thus.
>
> 1. values > mean + 1 std (sigma)
> 2. values > mean but < mean + 1 std (sigma)
> 3. values < mean but > mean + 1 std (sigma)
> 4. values < mean + 1 std (sigma).
>
> Then I randomly select a value from group 1 for the first property and I
> associate it with a randomly selected sample of the second property from
> its group 1. And so on through the total population. This gave me a very
> rough linear association between the two properties, but I am wondering
> whether I can do it in a simpler and better way.
>

Hi Sydney,

I feel like I would definitely be able to solve your problem if I
understood what you're talking about (I'm sure others here could as well).
Please don't be put off by this but I don't think you've explained it very
well.

Perhaps if you give an example of what the input and output of this
operation is supposed to look like then you would get a response. The
example might look like:

I have these arrays as input:

>>> property_a = [1, 6, 2, 4]
>>> property_b = [6, 3, 4, 6]

Then I want a function that gives me this output

>>> associated_values = myfunction(a, b)
>>> associated_values
[1, 3, 5, 2]

Some explanation why you want this, how you know that's the output you
want, and what any of it means would likely help...

If you already have something that does what you want then it would make
sense to show it but if your code is complicated then please try to
simplify it and use only a small amount of data when showing it here. There
is some advice for posting this kind of thing to a mailing list here:
http://sscce.org/

--
Oscar


More information about the Tutor mailing list