How to integrate a shifted lognormal distributed random variable

Technical Source
2 min readJul 8, 2022

--

Dear all,

I’m quite new to Matlab and struggeling to integrate a continuous random variable by two parts. In the beginning I assume W=1+w is lognormally distributed with mean = 1 and standard deviation of 0.05. The mean is specifically chosen such that w has a zero mean and has a support of [-1, Inf). I tried to integrate a hard coded version of a lognormal density. This doesn’t give me a useful result since log is not defined for -1 yet I tried the same procedure with W the result still doesn’t make sense.

% Generating random variable WW = lognrnd(0, 0.05, 1, 2000);% Shifting W to have lognormal random variable w with zero mean and
% has a support of [-1, Inf)
w = W - 1;% Transforming omega to s_w = a*w with a = 9.0083s_w = 9.0083*w;% My aim is now to integrate s_w from -1 to 0 and from 0 to Inf
% Since I can only integrate a continous random variable numerically I
% tried to hard code the density and use the integral function
%mu = mean(s_w);
%sigmasq = var(s_w);
%s_w = @(x) exp(-(log(x) - mu).^2./(2.*sigmasq)./(x.*sqrt(2.*pi.*sigmasq)));%S_neg = integral(@(x)s_w(x), -1, 0);
%S_pos = integral(@(x)s_w(x), 0, Inf);
%d = -S_neg/S_pos;% This does obviously not work because of the support of log yet I actually
% need to integrate
% Even my approach of tranforming W to s(W) doesn't work since both values
% are close to zero which they shouldn't be according to a density plot
s_W = 9.0083*W;mu = mean(s_W);
sigmasq = var(s_W);
s_W = @(x) exp(-(log(x) - mu).^2./(2.*sigmasq)./(x.*sqrt(2.*pi.*sigmasq)));S_neg = integral(@(x)s_W(x), (-1+mu), mu);
S_pos = integral(@(x)s_W(x), mu, Inf);
d = -S_neg/S_pos;

I hope I gave all the necessary information.

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

For the edited version of your post,

a=-1+mu;
b=mu;
sigma=sqrt(sigmasq);
Sneg = logncdf(b,mu,sigma) - logncdf(a,mu,sigma);
Spos = logncdf(b,mu,sigma,'upper');

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.