聯合概率分布怎么,兩組離散數據怎么聯合概率的方法分析

聯合概率分布怎么求

聯合概率分布怎么,兩組離散數據怎么聯合概率的方法分析

文章插圖
求聯合概率分布公式:F(x,y)=P{(X隨機變量(randomvariable)表示隨機試驗各種結果的實值單值函數 。隨機事件不論與數量是否直接有關,都可以數量化,即都能用數量化的方式表達 。
兩組離散數據怎么聯合概率的方法分析給定至少兩個隨機變量X,Y,…, 它們的聯合概率分布(Joint probability distribution)指的是每一個隨機變量的值落入特定范圍或者離散點集合內的概率. 對于只有兩個隨機變量的情況, 稱為二元分布(bivariate distribution).
聯合概率分布可以使用聯合累計分布函數(joint cumulative distribution function), 連續隨機變量的聯合概率密度函數(joint probability density function)或者離散變量的聯合概率質量函數(joint probability mass function)來描述. 由此又衍生出兩個概念: 邊緣分布(marginal distribution)和條件概率分布(conditional probability distribution).
二. 離散變量的聯合概率質量函數公式
公式:
是給定X=x的Y=y的條件概率.
而且有:
如果X和Y相互獨立:
【聯合概率分布怎么,兩組離散數據怎么聯合概率的方法分析】如果X和Y條件不獨立(conditionally dependent):
P(X=x and Y=y)=P(X=x)·P(Y=y|X=x)
也可以使用聯合累計分布函數的差分來計算:
聯合累計分布函數定義是:
所以F(x,y)的導數(差分)就是P(X=x and Y=y)
三. 使用Matlab計算離散2D聯合分布
參考: Calculating a 2D joint probability distribution
離散2D聯合分布可用于計算兩張圖片的互信息MI.
0. 定義兩個離散的隨機變量.
有N個點分布在邊長為1的正方形區域內. 把正方形分為K1*K2的小矩形. 統計每個小矩形內的點的個數.
% Data
N = 1e5; % number of points
xy = rand(N, 2); % coordinates of points
xy(randi(2*N, 100, 1)) = 0; % add some points on one side
xy(randi(2*N, 100, 1)) = 1; % add some points on the other side
xy(randi(N, 100, 1), :) = 0; % add some points on one corner
xy(randi(N, 100, 1), :) = 1; % add some points on one corner
inds= unique(randi(N, 100, 1));
xy(inds, :) = repmat([0 1], numel(inds), 1); % add some points on one corner
inds= unique(randi(N, 100, 1));
xy(inds, :) = repmat([1 0], numel(inds), 1); % add some points on one corner
% Intervals for rectangles
K1 = ceil(sqrt(N/5)); % number of intervals along x
K2 = K1; % number of intervals along y
int_x = [0:(1 / K1):1]; % intervals along x
int_y = [0:(1 / K2):1]; % intervals along y
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
1. 從定義出發, 使用for循環:
tic
count_cells = zeros(K1, K2);
for k1 = 1:K1
inds1 = (xy(:, 1) >= int_x(k1)) & (xy(:, 1) for k2 = 1:K2
inds2 = (xy(:, 2) >= int_y(k2)) & (xy(:, 2) count_cells(k1, k2) = sum(inds1 .* inds2);% 布爾相乘得到交集點的個數
end
end
toc
% Elapsed time is 39.357691 seconds.
1
2
3
4
5
6
7
8
9
10
11
1
2
3
4
5
6
7
8
9
10
11

    推薦閱讀