Skip to main content
Post Closed as "Duplicate" by jkuczm, gwr, C. E., xzczd, Henrik Schumacher
added tags
Link
gwr
  • 13.6k
  • 2
  • 48
  • 82
Use Python code bock.
Source Link
jkuczm
  • 15.1k
  • 2
  • 54
  • 85

What is the Mathematica equivalent of the following Python code with the vectors' broadcast addition?

import numpy as np

a = np.random.rand(5000, 1, 5);
b = np.random.rand(1, 500, 5);

result = a + b #shape: (5000, 500, 5) 
import numpy as np

a = np.random.rand(5000, 1, 5);
b = np.random.rand(1, 500, 5);

result = a + b #shape: (5000, 500, 5) 

What is the Mathematica equivalent of the following Python code with the vectors' broadcast addition?

import numpy as np

a = np.random.rand(5000, 1, 5);
b = np.random.rand(1, 500, 5);

result = a + b #shape: (5000, 500, 5) 

What is the Mathematica equivalent of the following Python code with the vectors' broadcast addition?

import numpy as np

a = np.random.rand(5000, 1, 5);
b = np.random.rand(1, 500, 5);

result = a + b #shape: (5000, 500, 5) 
added 24 characters in body
Source Link
C. E.
  • 71.2k
  • 6
  • 141
  • 269

What is the Mathematica equivalent of the following Python code with the vectors' broadcast addition?

import numpy as np

a = np.random.rand(5000, 1, 5);
b = np.random.rand(1, 500, 5);

result = a + b #shape: (5000, 500, 5) 

What is the Mathematica equivalent of the following Python code with the vectors' broadcast addition?

import numpy as np

a = np.random.rand(5000, 1, 5);
b = np.random.rand(1, 500, 5);

result = a + b

What is the Mathematica equivalent of the following Python code with the vectors' broadcast addition?

import numpy as np

a = np.random.rand(5000, 1, 5);
b = np.random.rand(1, 500, 5);

result = a + b #shape: (5000, 500, 5) 
Copy edited (e.g. ref. <http://en.wikipedia.org/wiki/NumPy> and <http://en.wikipedia.org/wiki/Python_%28programming_language%29>).
Source Link
Loading
added 5 characters in body
Source Link
Loading
added 2 characters in body
Source Link
Loading
Source Link
Loading