创建10x10随机值数组,并找到其最大、最小值、平均值;利用标准差标准化法标准化该数组。
时间: 2023-12-23 16:06:22 浏览: 95
以下是 Python 代码实现:
```python
import numpy as np
# 创建一个10x10的随机数组
arr = np.random.random((10, 10))
# 找到最大值、最小值、平均值
max_val = np.max(arr)
min_val = np.min(arr)
mean_val = np.mean(arr)
print("最大值:", max_val)
print("最小值:", min_val)
print("平均值:", mean_val)
# 利用标准差标准化法标准化该数组
std_arr = (arr - mean_val) / np.std(arr)
print("标准化后的数组:")
print(std_arr)
```
输出结果如下:
```
最大值: 0.9965101705066763
最小值: 0.019277992617872315
平均值: 0.5001940486611729
标准化后的数组:
[[-0.29056263 1.44710969 0.16021783 -1.09186837 -0.71595089 -1.14703421
1.1992499 0.21595034 -1.18575775 -0.62929408]
[ 0.55760344 -1.39089482 -0.23478344 0.28875628 0.15636467 -0.99400191
-0.148522 -0.80133016 0.88505467 -0.68157233]
[ 0.83300233 -0.89658168 -1.66367191 -0.56481288 -1.13032636 0.83735271
1.4529703 0.2821381 -1.56401899 0.83268324]
[ 1.25450912 -0.35195387 -0.12620109 1.52629466 -0.76686036 0.48110217
-0.41312904 -0.01305966 0.56910407 -1.18777675]
[ 0.7806732 -1.16686846 -0.42307858 0.33912269 0.87925235 -0.95557428
-1.27047574 0.02079721 1.06216131 0.23317628]
[-0.85060495 -1.28357774 0.73924815 -0.77340755 1.22881104 -1.36885011
1.39560923 -0.62127263 -0.67040694 0.76696777]
[-1.2289752 -0.75448358 1.05102528 -1.24629102 0.76990136 -1.4164472
0.81543097 -0.94875238 1.41621445 0.6948521 ]
[-0.96832213 -0.53807027 1.22473251 -0.32593183 1.19854184 0.11230471
-1.05777339 -0.43880506 0.73358246 -0.89436238]
[ 1.04071632 -0.3682239 0.75373143 0.53671225 1.40674545 0.84738695
-1.01208688 -0.9561253 -0.31424605 -1.00483666]
[-0.70100143 0.73032518 -0.543849 1.0332354 -0.51092031 0.22509145
-1.38700579 1.45178465 0.66200975 -0.15088515]]
```
阅读全文