亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Python:如何繪制3維數組的正態分布

Python:如何繪制3維數組的正態分布

一只斗牛犬 2021-05-10 16:29:27
我有一個3維數組temprSubset,它取了2維的平均值。代碼:f=MFDataset(filenames)temprSubset = f.variables['tc'][ : , latitude_lower_limit:latitude_upper_limit , longitude_lower_limit:longitude_upper_limit,] tempavg1=temprSubset.mean(axis=tuple(range(0,2)))我想繪制tempavg1數組中每個平均值的標準偏差曲線,但我很迷惑。
查看完整描述

1 回答

?
尚方寶劍之說

TA貢獻1788條經驗 獲得超4個贊

簡單的方法是使用該hist功能。箱數的選擇可能會大大改變圖形的形狀。


給出平滑曲線的另一種方法是核密度估計。帶寬的選擇也可能會更改獲得的圖形的形狀。


import numpy as np


import matplotlib.pyplot as plt

%matplotlib inline


# Generate some data

data = np.random.normal( size=(5, 50, 150) )  # a random 3D array

average_axes01 = data.mean(axis=(0, 1))


# Using the Kernel density estimation:

from scipy.stats import gaussian_kde


prob_density = gaussian_kde(average_axes01)

std = average_axes01.std()

x_fine = np.linspace(-3*std, 3*std, 29)

probs = prob_density(x_fine)

plt.plot(x_fine, probs, 'r', linewidth=2);


# Using the histogram:

plt.hist(average_axes01, bins=7, normed=True, alpha=.4)


plt.ylabel('probability density function'); plt.xlabel('values');

http://img1.sycdn.imooc.com//60a3653c0001828003850271.jpg

查看完整回答
反對 回復 2021-05-18
  • 1 回答
  • 0 關注
  • 215 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號