
% plotNormal1d(mean, variance, resolution, weight, style)
% 
% plots the values of a 1D normal distribution; if resolution is not given,
% the curve is sampled with 1000 points, otherwise the number of points 
% given is used; if weight is given (0<weight<=1), the gaussian is ratiod 
% accordingly; if style is given, the curve is plotted using this style 
% (color and linestyle); if zero is given, this value is used as the 
% minimum y value to plot, (i.e. it determines the width of the plotted 
% distribution)
% copyright (c) 2008 by thilo stadelmann, stadelmann@informatik.uni-marburg.de

function mLine = plotNormal1d(dimensions, weight, mean, variance, compvariances, resolution, style, zero)

    deltaX = sqrt(-2.0*variance*(log(zero)+0.5*log((2*pi)^dimensions*prod(compvariances)))); %this +- mean is the x-value where y reaches zero, the minimum y-value to plot

    t = 2*deltaX / resolution;                                        
    x = mean-deltaX : t : mean+deltaX;

    y = normal1d(x, dimensions, mean, variance, compvariances) * weight;
    mLine = plot(x, y, style,'LineWidth', 2,'XDATA', x, 'YDATA',y);
    set(gca, 'Box', 'on');


