You can use np.ufunc.reduce with multiple axis to get as array as you want.
(first find max on axis=1 from X1 , X2 then find max on axis=0 from result.)
np.maximum.reduce([X1, X2], axis=(1,0))
# array([4633.70349825])
np.minimum.reduce([X1, X2], axis=(1,0))
# array([319.09009796])
Or try this to get as value:
>>> np.max((X1,X2))
4633.70349825
>>> np.min((X1,X2))
319.09009796
Or try this to get as array:
>>> max(max(X1), max(X2))
array([4633.70349825])
>>> min(min(X1), min(X2))
array([319.09009796])
Answer from Mahdi F. on Stack Overflownumpy - Maximum and Minimum values from multiple arrays in Python - Stack Overflow
python - Element-wise array maximum function in NumPy (more than two arrays) - Stack Overflow
find mean of 2 numpy arrays without using the 0 values
Calculate max envelope function
You can use np.ufunc.reduce with multiple axis to get as array as you want.
(first find max on axis=1 from X1 , X2 then find max on axis=0 from result.)
np.maximum.reduce([X1, X2], axis=(1,0))
# array([4633.70349825])
np.minimum.reduce([X1, X2], axis=(1,0))
# array([319.09009796])
Or try this to get as value:
>>> np.max((X1,X2))
4633.70349825
>>> np.min((X1,X2))
319.09009796
Or try this to get as array:
>>> max(max(X1), max(X2))
array([4633.70349825])
>>> min(min(X1), min(X2))
array([319.09009796])
You need to wrap the arrays in a array-like object (list, tuple). See below:
ma = np.max([X1, X2])
mi = np.min([X1, X2])
print(ma)
print(mi)
Output
4633.70349825
319.09009796
By default both max and min will flatten the input, from the documentation:
axis None or int or tuple of ints, optional Axis or axes along which to operate. By default, flattened input is used.
With this setup:
>>> A = np.array([0,1,2])
>>> B = np.array([1,0,3])
>>> C = np.array([3,0,4])
You can either do:
>>> np.maximum.reduce([A,B,C])
array([3, 1, 4])
Or:
>>> np.vstack([A,B,C]).max(axis=0)
array([3, 1, 4])
I would go with the first option.
You can use reduce. It repeatedly applies a binary function to a list of values...
For A, B and C given in question...
np.maximum.reduce([A,B,C])
array([3,1,4])
It first computes the np.maximum of A and B and then computes the np.maximum of (np.maximum of A and B) and C.