% Create scenarios for lognormal variable
% by quantile-based stratification
function [values, probs] = MakeScenariosQ(numScenarios,mu,sigma)
% initialize output
probs = ones(numScenarios,1)/numScenarios;
values = zeros(numScenarios,1)';
% find extreme points of subintervals
y = zeros(numScenarios+1,1);
for h = 1:(numScenarios-1)
    P = h/numScenarios;
    y(h+1) = logninv(P,mu,sigma);
end
y(numScenarios+1) = exp(mu+20*sigma);
f = @(x) x.*lognpdf(x,mu,sigma);
% find expected values by integrating pdf on each subinterval
for h=1:numScenarios
    values(h)=integral(f,y(h),y(h+1))*numScenarios;
end

