像这样的东西?
clear all; close all; clc;
format compact
pat=rand(2,500); %500 samples with 2 features each
target=rand(1,500)>0.5; %w0 and w1 assignments
edges=[0:0.1:1];
pat1_w0=histc(pat(1,target==0),edges); %x1|w0
pat1_w0=pat1_w0/sum(pat1_w0); %normalize
pat2_w0=histc(pat(2,target==0),edges); %x2|w0
pat2_w0=pat2_w0/sum(pat1_w0); %normalize
pat1_w1=histc(pat(1,target==1),edges); %x1|w1
pat1_w1=pat1_w1/sum(pat1_w0); %normalize
pat2_w1=histc(pat(2,target==1),edges); %x2|w1
pat2_w1=pat2_w1/sum(pat1_w0); %normalize
figure
hold on
bar(pat1_w0,'r') %insert whatever variable here to graph
bar(pat2_w0,'g')
bar(pat1_w1,'b')
bar(pat2_w1,'y')