I have two array X and Y. I am trying to find:
0.5x0 0.25x1 0.125x12 0.0625x3 0.03125x4
and so on for other rows of X. Multiply values in Y(starting from 1st index) to values in each row of X.
So output array should be same size as X. Was wondering if there was any built in function available to achieve this?
You should just be able to use the *
operator, and slice Y[1:]
to drop the first element
>>> X * Y[1:]
array([[0. , 0.25 , 1.5 , 0.1875 , 0.125 ],
[2.5 , 4. , 0.875 , 0.5 , 0.28125],
[0. , 2.75 , 1.5 , 0.8125 , 0.125 ],
[7.5 , 4. , 2.125 , 0.5 , 0.59375],
[0. , 0.25 , 1.5 , 0.1875 , 0.125 ],
[2.5 , 4. , 0.875 , 0.5 , 0.40625],
[2. , 3.75 , 0. , 0.3125 , 0. ]])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.