【问题标题】:How to plot two 1-dimensional Gaussian distributions together with the classification boundary [Matlab]?如何绘制两个一维高斯分布和分类边界[Matlab]?
【发布时间】:2013-04-14 01:06:16
【问题描述】:

我有两个类(正态分布),C1 和 C2,每个类都由它们的平均值和标准差定义。我希望能够可视化正态分布的 pdf 图和两者之间的分类边界。目前我有绘制分布的代码,但我不确定如何绘制决策边界。任何想法,将不胜感激。我已经包含了我想要绘制的样本。 1

非常感谢!

【问题讨论】:

    标签: matlab plot gaussian boundary


    【解决方案1】:

    这是我想出的:

    % Generate some example data
    mu1 = -0.5; sigma1 = 0.7; mu2 = 0.8; sigma2 = 0.5;
    x = linspace(-8, 8, 500);
    y1 = normpdf(x, mu1, sigma1);
    y2 = normpdf(x, mu2, sigma2);
    
    % Plot it
    figure; plot(x, [y1; y2])
    hold on
    
    % Detect intersection between curves; choose threshold so you get the whole 
    % intersection (0.0001 should do unless your sigmas are very large)
    ind = y1 .* y2 > 0.0001;
    % Find the minimum values in range
    minVals = min([y1(ind); y2(ind)]);
    
    if ~isempty(minVals)
        area(x(ind), minVals)
    end
    

    我不知道这是否是做你想做的最好的方式,但它似乎工作。

    【讨论】:

      猜你喜欢
      • 2013-01-30
      • 2013-11-03
      • 2011-04-10
      • 2012-03-02
      • 2015-04-09
      • 1970-01-01
      • 2017-11-24
      • 2013-02-02
      • 1970-01-01
      相关资源
      最近更新 更多