Hello,
I have 2*N arrays (let's say 2 arrays of length 4) that I combine using np.meshgrid
xxA, yyA = np.meshgrid(xA, yA)
xxB, yyB = np.meshgrid(xB, yB)
which gives me two meshes
xx.shape = yy.shape = (4,4)
wish represent N-dimensional mesh with 16 elements.
Now I want to evaluate a function f on every possible pair of N-dimensional points in the grid, resulting in a 16 x 16
matrix:
in a flattened notation, pA = (xxA, yyA)
f(pA[1]-pB[1]) f(pA[1]-pB[2]) f(pA[1]-pB[3]) ...
f(pA[2]-pB[1]) f(…
[View More]pA[2]-pB[2]) f(pA[2]-pB[3]) ...
f(pA[3]-pB[1]) f(pA[3]-pB[2]) f(pA[3]-pB[3]) ...
.
.
.
Let's say xA = yA = [1,2,3] and xB = yB = [10,20,30]
that gives me a mesh A:
(1,3) (2,3) (3,3)
(1,2) (2,2) (3,2)
(1,1) (2,1) (3,1)
and a mesh B alike.
My result matrix now should be of size 9 x 9:
f( (1,3), (10,30) ) f( (2,3), (20,30) ) f( (3,3), (30, 30) )
f( (1,2), (10,20) ) f( (2,2), (20,20) ) f( (3,2), (30, 20) )
...
f always takes two N-dimensional vectors and returns a scalar.
I hope I was able to explain what I want to achieve.
What is the best way to do that in numpy?
Thanks,
Florian
[View Less]
Hi numpy users,
This email is regarding the discussion on how np.ma.polyfit should deal
with non-uniform mask across columns in 2D data array.
Github Issue#9193 [ https://github.com/numpy/numpy/issues/9193 ]
Current behaviour of np.ma.polyfit is to union combine all the column masks
across all the columns and do the polynomial fit for all columns using this
same mask.
This has the potentially undesired behaviour of masking out lots of data
across the columns if just one column has a certain …
[View More]row masked out.
Since the polynomial fit of data in each column is independent, it seems to
be an undesired behaviour.
We were thinking to change this behaviour by fitting columns with different
mask, separately.
What are the opinions on this in regards to backward compatibility?
Was there any usecase for the previous behaviour?
Also, any implementation ideas/suggestions on the plan currently being
discussed in Issue#9193 page.
Thanks,
-cheers
Joe
--
/---------------------------------------------------------------
"GNU/Linux: because a PC is a terrible thing to waste" - GNU Generation
************************************************
Joe Philip Ninan
Postdoctoral Researcher
406 Davey Lab,
Dept. of Astronomy & Astrophysics
The Pennsylvania State University
University Park, PA-16802
------------------------------------------------------------
Website: https://indiajoe.gitlab.io/
My GnuPG Public Key: https://indiajoe.gitlab.io/files/JPN_public.key
[View Less]