为何均匀分布输入下的行列式与迹散点图不符合预期?
二维线性系统稳定性分析中的散点图异常问题
研究背景
我正在研究二维线性系统的各类稳定性概率,系统对应的矩阵为:
[[a,b], [c,d]]
其中a、b、c、d均取自[-1,1]区间的均匀分布,核心分析方向是迹(a+d)与行列式(ad-bc)的散点图(参考稳定性分类图)。
实现代码
使用numpy生成随机矩阵的代码如下:
import numpy as np import matplotlib.pyplot as plt det = [] # determinant tr = [] # trace i=0 while i < 100000: linsys = np.random.uniform(-1, 1, size=(2,2)) tr.append(linsys[0][0]+linsys[1][1]) det.append(linsys[0][0]*linsys[1][1]-linsys[1][0]*linsys[0][1]) i += 1 print(np.max(tr),np.max(det),np.min(tr),np.min(det)) plt.scatter(det,tr) plt.title("Plot of Trace v Determinant") plt.xlabel("a*d-c*b") plt.ylabel("a+d") #plt.scatter(np.abs(det),2*np.sqrt(np.abs(det))) #plt.scatter(np.abs(det),-2*np.sqrt(np.abs(det))) fig1, ax1 = plt.subplots(figsize =(6, 4)) ax1.hist(det, bins = [-3,-2,-1,0,1,2,3]) plt.title('Histogram of trace') fig2, ax2 = plt.subplots(figsize =(6, 4)) ax2.hist(trace, bins = [-3,-2,-1,0,1,2,3]) plt.title('Histogram of determinant')
问题与疑惑
原本预期迹与行列式的散点图会呈现均匀分布,但实际生成的散点图出现了异常形状,同时迹和行列式的分布直方图也不符合预期。想请教:出现这种异常形状的原因是什么?是矩阵的生成方式存在错误吗?
内容的提问来源于stack exchange,提问作者jay
相关产品推荐
相关产品推荐

