You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One might wonder why the functions are called `amax` and `amin` and not `max` and `min` or why the other is called `mean` and not `amean`.
384
-
The package `numpy` does provide functions `max` and `min` that are fully equivalent to `amax` and `amin`, but they share a name with standard library functions `max` and `min` that come with Python itself.
385
-
Referring to the functions like we did above, that is `numpy.max` for example, does not cause problems, but there are other ways to refer to them that could.
386
-
In addition, text editors might highlight (color) these functions like standard library function, even though they belong to NumPy, which can be confusing and lead to errors.
387
-
Since there is no function called `mean` in the standard library, there is no function called `amean`.
@@ -397,7 +385,7 @@ then ask it to do the calculation:
397
385
398
386
```python
399
387
patient_0 = data[0, :] # 0 on the first axis (rows), everything on the second (columns)
400
-
print('maximum inflammation for patient 0:', numpy.amax(patient_0))
388
+
print('maximum inflammation for patient 0:', numpy.max(patient_0))
401
389
```
402
390
403
391
```output
@@ -408,7 +396,7 @@ We don't actually need to store the row in a variable of its own.
408
396
Instead, we can combine the selection and the function call:
409
397
410
398
```python
411
-
print('maximum inflammation for patient 2:', numpy.amax(data[2, :]))
399
+
print('maximum inflammation for patient 2:', numpy.max(data[2, :]))
412
400
```
413
401
414
402
```output
@@ -420,11 +408,11 @@ next diagram on the left) or the average for each day (as in the
420
408
diagram on the right)? As the diagram below shows, we want to perform the
421
409
operation across an axis:
422
410
423
-
{alt="Per-patient maximum inflammation is computed row-wise across all columns usingnumpy.amax(data, axis=1). Per-day average inflammation is computed column-wise across all rows usingnumpy.mean(data, axis=0)."}
411
+
{alt="Per-patient maximum inflammation is computed row-wise across all columns usingnumpy.max(data, axis=1). Per-day average inflammation is computed column-wise across all rows usingnumpy.mean(data, axis=0)."}
424
412
425
-
To find the **maximum inflammation reported for each patient**, you would apply the `max` function moving across the columns (axis 1). To find the **daily average inflammation reported across patients**, you would apply the `mean` function moving down the rows (axis 0).
413
+
To find the **maximum inflammation reported for each patient**, you would apply the `max` function moving across the columns (axis 1). To find the **daily average inflammation reported across patients**, you would apply the `mean` function moving down the rows (axis 0).
426
414
427
-
To support this functionality, most array functions allow us to specify the axis we want to work on. If we ask for the max across axis 1 (columns in our 2D example), we get:
415
+
To support this functionality, most array functions allow us to specify the axis we want to work on. If we ask for the maximum across axis 1 (columns in our 2D example), we get:
0 commit comments