Anti-derivative of Lognormal CDFsolving/approximating integral of lognormal cdfMaxwell-Boltzmann velocity PDF to CDFWhat is $mathbbEleft[fracx1+bxright]$ where $x$ is lognormalNumerical CDF of sum of dependent lognormal variablesHow to prove that given CDF is valid?Expected Value of Maximum of Two Lognormal Random Variables with One Source of RandomnessExpected Value of Maximum of Two Lognormal Random Variablessolving/approximating integral of lognormal cdfExpected value of a lognormal distributionBounds on the two first moments of the absolute value of a random variable?Expectation of maximum of two lognormal random variables (another view)
Where does SFDX store details about scratch orgs?
Facing a paradox: Earnshaw's theorem in one dimension
I Accidentally Deleted a Stock Terminal Theme
Blender 2.8 I can't see vertices, edges or faces in edit mode
90's TV series where a boy goes to another dimension through portal near power lines
Can a rocket refuel on Mars from water?
UK: Is there precedent for the governments e-petition site changing the direction of a government decision?
How badly should I try to prevent a user from XSSing themselves?
Can I ask the recruiters in my resume to put the reason why I am rejected?
Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?
Western buddy movie with a supernatural twist where a woman turns into an eagle at the end
Is it possible to download Internet Explorer on my Mac running OS X El Capitan?
Brothers & sisters
Took a trip to a parallel universe, need help deciphering
How do I write bicross product symbols in latex?
How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?
Arrow those variables!
Why does Arabsat 6A need a Falcon Heavy to launch
How much of data wrangling is a data scientist's job?
Is the Joker left-handed?
Is there a hemisphere-neutral way of specifying a season?
prove that the matrix A is diagonalizable
Anagram holiday
A reference to a well-known characterization of scattered compact spaces
Anti-derivative of Lognormal CDF
solving/approximating integral of lognormal cdfMaxwell-Boltzmann velocity PDF to CDFWhat is $mathbbEleft[fracx1+bxright]$ where $x$ is lognormalNumerical CDF of sum of dependent lognormal variablesHow to prove that given CDF is valid?Expected Value of Maximum of Two Lognormal Random Variables with One Source of RandomnessExpected Value of Maximum of Two Lognormal Random Variablessolving/approximating integral of lognormal cdfExpected value of a lognormal distributionBounds on the two first moments of the absolute value of a random variable?Expectation of maximum of two lognormal random variables (another view)
$begingroup$
I am trying to solve the integral
beginequation
int_0^bPhi_LN(x, mu,sigma)dx
endequation
where beginequation Phi_LN(x, mu,sigma) = int^x_0frac1sqrt2pisigmayexpleft(-frac12left(fraclog y-musigmaright)^2right)dy endequation is the lognormal cdf, evaluated at x.
I found a solution to this question in this thread.
It says the function beginequationI(x) = xPhi_LN(x, mu,sigma) + L(x)endequation
with
beginequationL(x) = frac12e^(mu+sigma^2)/2mboxerfleft(left(sigma - fraclog(x)-musigmaright)/sqrt2right)endequation
is the anti-derivative of the LogNormal CDF.
This makes sense to me as because of $fracddxmboxerf(x) = frac2sqrtpie^-x²$ we get
beginalign
fracddx L(x) &= -frac12e^(mu+sigma^2)/2frac2sqrtpie^-frac12left(sigma - fraclog(x)-musigmaright)^2frac1xsigmasqrt2\
&= -frac1xsigmasqrt2pie^(mu+sigma^2)/2e^-frac12left(sigma^2 + left(fraclog(x)-musigmaright)^2 - 2(log(x)-mu)right)\
&= -frac1xsigmasqrt2pie^(mu+sigma^2)/2e^-frac12sigma^2e^-frac12left(fraclog(x)-musigmaright)^2e^log(x)e^-frac12mu\
&= -frac1sigmasqrt2pie^-frac12left(fraclog(x)-musigmaright)^2\
&= -frac1sigmavarphileft(fraclog(x)-musigmaright).
endalign
which implies that
beginalign
fracddxI(x) &= Phi_LN(x, mu,sigma) + xfracddxPhi_LN(x, mu,sigma) - frac1sigmavarphileft(fraclog(x)-musigmaright)\
&= Phi_LN(x, mu,sigma).
endalign
In order to test this result I wrote the following short R Script.
erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1
L_function<-function(x,mu,sigma)
z<-(sigma^2-log(x)+mu)/sigma
z<-z/sqrt(2)
y<-0.5*exp(0.5*(mu+sigma^2))
return(y*erf(z))
I_function<-function(x,mu,sigma)
return(x*plnorm(x,meanlog = mu,sdlog = sigma)+L_function(x,mu,sigma))
integral_over_LogNormalCDF<-function(lowerBound,upperBound,mu,sigma)
return(I_function(upperBound,mu,sigma)-I_function(lowerBound,mu,sigma))
ded<-2
limit<-3
mu<-1
sigma<-3
n=10000
steplength=0.0001
lognormalCDF<-seq(from=ded,to=limit,by=steplength)
lognormalCDF<-plnorm(lognormalCDF,meanlog = mu,sdlog = sigma)
weights<-replicate(length(lognormalCDF),steplength)
simulated<-lognormalCDF %*% weights
funcValue<-integral_over_LogNormalCDF(ded,limit,mu,sigma)
The results are fine (i.e. simulated equals funcValue) except when $mu neq 0$.
For example:
$mu=10$ -> simulated = 0.00123 and funcValue=0.002579
$mu=1$ -> simulated = 0.488 and funcValue=0.540
$mu=-1$ -> simulated = 0.738 and funcValue=0.667
Does anyone see my mistake?
Thanks in advance
Mathias
probability
$endgroup$
add a comment |
$begingroup$
I am trying to solve the integral
beginequation
int_0^bPhi_LN(x, mu,sigma)dx
endequation
where beginequation Phi_LN(x, mu,sigma) = int^x_0frac1sqrt2pisigmayexpleft(-frac12left(fraclog y-musigmaright)^2right)dy endequation is the lognormal cdf, evaluated at x.
I found a solution to this question in this thread.
It says the function beginequationI(x) = xPhi_LN(x, mu,sigma) + L(x)endequation
with
beginequationL(x) = frac12e^(mu+sigma^2)/2mboxerfleft(left(sigma - fraclog(x)-musigmaright)/sqrt2right)endequation
is the anti-derivative of the LogNormal CDF.
This makes sense to me as because of $fracddxmboxerf(x) = frac2sqrtpie^-x²$ we get
beginalign
fracddx L(x) &= -frac12e^(mu+sigma^2)/2frac2sqrtpie^-frac12left(sigma - fraclog(x)-musigmaright)^2frac1xsigmasqrt2\
&= -frac1xsigmasqrt2pie^(mu+sigma^2)/2e^-frac12left(sigma^2 + left(fraclog(x)-musigmaright)^2 - 2(log(x)-mu)right)\
&= -frac1xsigmasqrt2pie^(mu+sigma^2)/2e^-frac12sigma^2e^-frac12left(fraclog(x)-musigmaright)^2e^log(x)e^-frac12mu\
&= -frac1sigmasqrt2pie^-frac12left(fraclog(x)-musigmaright)^2\
&= -frac1sigmavarphileft(fraclog(x)-musigmaright).
endalign
which implies that
beginalign
fracddxI(x) &= Phi_LN(x, mu,sigma) + xfracddxPhi_LN(x, mu,sigma) - frac1sigmavarphileft(fraclog(x)-musigmaright)\
&= Phi_LN(x, mu,sigma).
endalign
In order to test this result I wrote the following short R Script.
erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1
L_function<-function(x,mu,sigma)
z<-(sigma^2-log(x)+mu)/sigma
z<-z/sqrt(2)
y<-0.5*exp(0.5*(mu+sigma^2))
return(y*erf(z))
I_function<-function(x,mu,sigma)
return(x*plnorm(x,meanlog = mu,sdlog = sigma)+L_function(x,mu,sigma))
integral_over_LogNormalCDF<-function(lowerBound,upperBound,mu,sigma)
return(I_function(upperBound,mu,sigma)-I_function(lowerBound,mu,sigma))
ded<-2
limit<-3
mu<-1
sigma<-3
n=10000
steplength=0.0001
lognormalCDF<-seq(from=ded,to=limit,by=steplength)
lognormalCDF<-plnorm(lognormalCDF,meanlog = mu,sdlog = sigma)
weights<-replicate(length(lognormalCDF),steplength)
simulated<-lognormalCDF %*% weights
funcValue<-integral_over_LogNormalCDF(ded,limit,mu,sigma)
The results are fine (i.e. simulated equals funcValue) except when $mu neq 0$.
For example:
$mu=10$ -> simulated = 0.00123 and funcValue=0.002579
$mu=1$ -> simulated = 0.488 and funcValue=0.540
$mu=-1$ -> simulated = 0.738 and funcValue=0.667
Does anyone see my mistake?
Thanks in advance
Mathias
probability
$endgroup$
$begingroup$
How do the values compare when $mu=1$? (Are you sure the differences are large enough to not reflect rounding, or the imprecision of numerical integration?) What about $mu=-1$?
$endgroup$
– J.G.
Mar 21 at 12:43
$begingroup$
You could edit your question to share them.
$endgroup$
– J.G.
Mar 21 at 13:19
$begingroup$
I don't yet see the mistake however using numerical integration in Mathematica agrees completely with the simulated values and not with thefuncValue. So I suspect it has something to do withfuncValue.
$endgroup$
– JimB
Mar 21 at 15:14
add a comment |
$begingroup$
I am trying to solve the integral
beginequation
int_0^bPhi_LN(x, mu,sigma)dx
endequation
where beginequation Phi_LN(x, mu,sigma) = int^x_0frac1sqrt2pisigmayexpleft(-frac12left(fraclog y-musigmaright)^2right)dy endequation is the lognormal cdf, evaluated at x.
I found a solution to this question in this thread.
It says the function beginequationI(x) = xPhi_LN(x, mu,sigma) + L(x)endequation
with
beginequationL(x) = frac12e^(mu+sigma^2)/2mboxerfleft(left(sigma - fraclog(x)-musigmaright)/sqrt2right)endequation
is the anti-derivative of the LogNormal CDF.
This makes sense to me as because of $fracddxmboxerf(x) = frac2sqrtpie^-x²$ we get
beginalign
fracddx L(x) &= -frac12e^(mu+sigma^2)/2frac2sqrtpie^-frac12left(sigma - fraclog(x)-musigmaright)^2frac1xsigmasqrt2\
&= -frac1xsigmasqrt2pie^(mu+sigma^2)/2e^-frac12left(sigma^2 + left(fraclog(x)-musigmaright)^2 - 2(log(x)-mu)right)\
&= -frac1xsigmasqrt2pie^(mu+sigma^2)/2e^-frac12sigma^2e^-frac12left(fraclog(x)-musigmaright)^2e^log(x)e^-frac12mu\
&= -frac1sigmasqrt2pie^-frac12left(fraclog(x)-musigmaright)^2\
&= -frac1sigmavarphileft(fraclog(x)-musigmaright).
endalign
which implies that
beginalign
fracddxI(x) &= Phi_LN(x, mu,sigma) + xfracddxPhi_LN(x, mu,sigma) - frac1sigmavarphileft(fraclog(x)-musigmaright)\
&= Phi_LN(x, mu,sigma).
endalign
In order to test this result I wrote the following short R Script.
erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1
L_function<-function(x,mu,sigma)
z<-(sigma^2-log(x)+mu)/sigma
z<-z/sqrt(2)
y<-0.5*exp(0.5*(mu+sigma^2))
return(y*erf(z))
I_function<-function(x,mu,sigma)
return(x*plnorm(x,meanlog = mu,sdlog = sigma)+L_function(x,mu,sigma))
integral_over_LogNormalCDF<-function(lowerBound,upperBound,mu,sigma)
return(I_function(upperBound,mu,sigma)-I_function(lowerBound,mu,sigma))
ded<-2
limit<-3
mu<-1
sigma<-3
n=10000
steplength=0.0001
lognormalCDF<-seq(from=ded,to=limit,by=steplength)
lognormalCDF<-plnorm(lognormalCDF,meanlog = mu,sdlog = sigma)
weights<-replicate(length(lognormalCDF),steplength)
simulated<-lognormalCDF %*% weights
funcValue<-integral_over_LogNormalCDF(ded,limit,mu,sigma)
The results are fine (i.e. simulated equals funcValue) except when $mu neq 0$.
For example:
$mu=10$ -> simulated = 0.00123 and funcValue=0.002579
$mu=1$ -> simulated = 0.488 and funcValue=0.540
$mu=-1$ -> simulated = 0.738 and funcValue=0.667
Does anyone see my mistake?
Thanks in advance
Mathias
probability
$endgroup$
I am trying to solve the integral
beginequation
int_0^bPhi_LN(x, mu,sigma)dx
endequation
where beginequation Phi_LN(x, mu,sigma) = int^x_0frac1sqrt2pisigmayexpleft(-frac12left(fraclog y-musigmaright)^2right)dy endequation is the lognormal cdf, evaluated at x.
I found a solution to this question in this thread.
It says the function beginequationI(x) = xPhi_LN(x, mu,sigma) + L(x)endequation
with
beginequationL(x) = frac12e^(mu+sigma^2)/2mboxerfleft(left(sigma - fraclog(x)-musigmaright)/sqrt2right)endequation
is the anti-derivative of the LogNormal CDF.
This makes sense to me as because of $fracddxmboxerf(x) = frac2sqrtpie^-x²$ we get
beginalign
fracddx L(x) &= -frac12e^(mu+sigma^2)/2frac2sqrtpie^-frac12left(sigma - fraclog(x)-musigmaright)^2frac1xsigmasqrt2\
&= -frac1xsigmasqrt2pie^(mu+sigma^2)/2e^-frac12left(sigma^2 + left(fraclog(x)-musigmaright)^2 - 2(log(x)-mu)right)\
&= -frac1xsigmasqrt2pie^(mu+sigma^2)/2e^-frac12sigma^2e^-frac12left(fraclog(x)-musigmaright)^2e^log(x)e^-frac12mu\
&= -frac1sigmasqrt2pie^-frac12left(fraclog(x)-musigmaright)^2\
&= -frac1sigmavarphileft(fraclog(x)-musigmaright).
endalign
which implies that
beginalign
fracddxI(x) &= Phi_LN(x, mu,sigma) + xfracddxPhi_LN(x, mu,sigma) - frac1sigmavarphileft(fraclog(x)-musigmaright)\
&= Phi_LN(x, mu,sigma).
endalign
In order to test this result I wrote the following short R Script.
erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1
L_function<-function(x,mu,sigma)
z<-(sigma^2-log(x)+mu)/sigma
z<-z/sqrt(2)
y<-0.5*exp(0.5*(mu+sigma^2))
return(y*erf(z))
I_function<-function(x,mu,sigma)
return(x*plnorm(x,meanlog = mu,sdlog = sigma)+L_function(x,mu,sigma))
integral_over_LogNormalCDF<-function(lowerBound,upperBound,mu,sigma)
return(I_function(upperBound,mu,sigma)-I_function(lowerBound,mu,sigma))
ded<-2
limit<-3
mu<-1
sigma<-3
n=10000
steplength=0.0001
lognormalCDF<-seq(from=ded,to=limit,by=steplength)
lognormalCDF<-plnorm(lognormalCDF,meanlog = mu,sdlog = sigma)
weights<-replicate(length(lognormalCDF),steplength)
simulated<-lognormalCDF %*% weights
funcValue<-integral_over_LogNormalCDF(ded,limit,mu,sigma)
The results are fine (i.e. simulated equals funcValue) except when $mu neq 0$.
For example:
$mu=10$ -> simulated = 0.00123 and funcValue=0.002579
$mu=1$ -> simulated = 0.488 and funcValue=0.540
$mu=-1$ -> simulated = 0.738 and funcValue=0.667
Does anyone see my mistake?
Thanks in advance
Mathias
probability
probability
edited Mar 21 at 13:24
mathimathi1987
asked Mar 21 at 12:29
mathimathi1987mathimathi1987
32
32
$begingroup$
How do the values compare when $mu=1$? (Are you sure the differences are large enough to not reflect rounding, or the imprecision of numerical integration?) What about $mu=-1$?
$endgroup$
– J.G.
Mar 21 at 12:43
$begingroup$
You could edit your question to share them.
$endgroup$
– J.G.
Mar 21 at 13:19
$begingroup$
I don't yet see the mistake however using numerical integration in Mathematica agrees completely with the simulated values and not with thefuncValue. So I suspect it has something to do withfuncValue.
$endgroup$
– JimB
Mar 21 at 15:14
add a comment |
$begingroup$
How do the values compare when $mu=1$? (Are you sure the differences are large enough to not reflect rounding, or the imprecision of numerical integration?) What about $mu=-1$?
$endgroup$
– J.G.
Mar 21 at 12:43
$begingroup$
You could edit your question to share them.
$endgroup$
– J.G.
Mar 21 at 13:19
$begingroup$
I don't yet see the mistake however using numerical integration in Mathematica agrees completely with the simulated values and not with thefuncValue. So I suspect it has something to do withfuncValue.
$endgroup$
– JimB
Mar 21 at 15:14
$begingroup$
How do the values compare when $mu=1$? (Are you sure the differences are large enough to not reflect rounding, or the imprecision of numerical integration?) What about $mu=-1$?
$endgroup$
– J.G.
Mar 21 at 12:43
$begingroup$
How do the values compare when $mu=1$? (Are you sure the differences are large enough to not reflect rounding, or the imprecision of numerical integration?) What about $mu=-1$?
$endgroup$
– J.G.
Mar 21 at 12:43
$begingroup$
You could edit your question to share them.
$endgroup$
– J.G.
Mar 21 at 13:19
$begingroup$
You could edit your question to share them.
$endgroup$
– J.G.
Mar 21 at 13:19
$begingroup$
I don't yet see the mistake however using numerical integration in Mathematica agrees completely with the simulated values and not with the
funcValue. So I suspect it has something to do with funcValue.$endgroup$
– JimB
Mar 21 at 15:14
$begingroup$
I don't yet see the mistake however using numerical integration in Mathematica agrees completely with the simulated values and not with the
funcValue. So I suspect it has something to do with funcValue.$endgroup$
– JimB
Mar 21 at 15:14
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
The I_function is not correct. Your R code should be more like the following.
erfc <- function(x) 1 - (2 * pnorm(x * sqrt(2)) - 1)
I_function<-function(x,mu,sigma)
return( (x*erfc((mu - log(x))/(sqrt(2)*sigma)) -
exp(mu + sigma**2/2)*erfc((mu + sigma**2 - log(x))/(sqrt(2)*sigma)))/2)
integral_over_LogNormalCDF<-function(lowerBound,upperBound,mu,sigma)
return(I_function(upperBound,mu,sigma)-I_function(lowerBound,mu,sigma))
The test values you used result in the following:
integral_over_LogNormalCDF(2,3,10,3)
# 0.001231376
integral_over_LogNormalCDF(2,3,1,3)
# 0.4879823
integral_over_LogNormalCDF(2,3,-1,3)
# 0.7376231
$endgroup$
$begingroup$
Hi JimB, thank you for your help! Much appreciated!
$endgroup$
– mathimathi1987
Mar 23 at 14:57
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "69"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3156766%2fanti-derivative-of-lognormal-cdf%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
The I_function is not correct. Your R code should be more like the following.
erfc <- function(x) 1 - (2 * pnorm(x * sqrt(2)) - 1)
I_function<-function(x,mu,sigma)
return( (x*erfc((mu - log(x))/(sqrt(2)*sigma)) -
exp(mu + sigma**2/2)*erfc((mu + sigma**2 - log(x))/(sqrt(2)*sigma)))/2)
integral_over_LogNormalCDF<-function(lowerBound,upperBound,mu,sigma)
return(I_function(upperBound,mu,sigma)-I_function(lowerBound,mu,sigma))
The test values you used result in the following:
integral_over_LogNormalCDF(2,3,10,3)
# 0.001231376
integral_over_LogNormalCDF(2,3,1,3)
# 0.4879823
integral_over_LogNormalCDF(2,3,-1,3)
# 0.7376231
$endgroup$
$begingroup$
Hi JimB, thank you for your help! Much appreciated!
$endgroup$
– mathimathi1987
Mar 23 at 14:57
add a comment |
$begingroup$
The I_function is not correct. Your R code should be more like the following.
erfc <- function(x) 1 - (2 * pnorm(x * sqrt(2)) - 1)
I_function<-function(x,mu,sigma)
return( (x*erfc((mu - log(x))/(sqrt(2)*sigma)) -
exp(mu + sigma**2/2)*erfc((mu + sigma**2 - log(x))/(sqrt(2)*sigma)))/2)
integral_over_LogNormalCDF<-function(lowerBound,upperBound,mu,sigma)
return(I_function(upperBound,mu,sigma)-I_function(lowerBound,mu,sigma))
The test values you used result in the following:
integral_over_LogNormalCDF(2,3,10,3)
# 0.001231376
integral_over_LogNormalCDF(2,3,1,3)
# 0.4879823
integral_over_LogNormalCDF(2,3,-1,3)
# 0.7376231
$endgroup$
$begingroup$
Hi JimB, thank you for your help! Much appreciated!
$endgroup$
– mathimathi1987
Mar 23 at 14:57
add a comment |
$begingroup$
The I_function is not correct. Your R code should be more like the following.
erfc <- function(x) 1 - (2 * pnorm(x * sqrt(2)) - 1)
I_function<-function(x,mu,sigma)
return( (x*erfc((mu - log(x))/(sqrt(2)*sigma)) -
exp(mu + sigma**2/2)*erfc((mu + sigma**2 - log(x))/(sqrt(2)*sigma)))/2)
integral_over_LogNormalCDF<-function(lowerBound,upperBound,mu,sigma)
return(I_function(upperBound,mu,sigma)-I_function(lowerBound,mu,sigma))
The test values you used result in the following:
integral_over_LogNormalCDF(2,3,10,3)
# 0.001231376
integral_over_LogNormalCDF(2,3,1,3)
# 0.4879823
integral_over_LogNormalCDF(2,3,-1,3)
# 0.7376231
$endgroup$
The I_function is not correct. Your R code should be more like the following.
erfc <- function(x) 1 - (2 * pnorm(x * sqrt(2)) - 1)
I_function<-function(x,mu,sigma)
return( (x*erfc((mu - log(x))/(sqrt(2)*sigma)) -
exp(mu + sigma**2/2)*erfc((mu + sigma**2 - log(x))/(sqrt(2)*sigma)))/2)
integral_over_LogNormalCDF<-function(lowerBound,upperBound,mu,sigma)
return(I_function(upperBound,mu,sigma)-I_function(lowerBound,mu,sigma))
The test values you used result in the following:
integral_over_LogNormalCDF(2,3,10,3)
# 0.001231376
integral_over_LogNormalCDF(2,3,1,3)
# 0.4879823
integral_over_LogNormalCDF(2,3,-1,3)
# 0.7376231
answered Mar 21 at 15:46
JimBJimB
61547
61547
$begingroup$
Hi JimB, thank you for your help! Much appreciated!
$endgroup$
– mathimathi1987
Mar 23 at 14:57
add a comment |
$begingroup$
Hi JimB, thank you for your help! Much appreciated!
$endgroup$
– mathimathi1987
Mar 23 at 14:57
$begingroup$
Hi JimB, thank you for your help! Much appreciated!
$endgroup$
– mathimathi1987
Mar 23 at 14:57
$begingroup$
Hi JimB, thank you for your help! Much appreciated!
$endgroup$
– mathimathi1987
Mar 23 at 14:57
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3156766%2fanti-derivative-of-lognormal-cdf%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
How do the values compare when $mu=1$? (Are you sure the differences are large enough to not reflect rounding, or the imprecision of numerical integration?) What about $mu=-1$?
$endgroup$
– J.G.
Mar 21 at 12:43
$begingroup$
You could edit your question to share them.
$endgroup$
– J.G.
Mar 21 at 13:19
$begingroup$
I don't yet see the mistake however using numerical integration in Mathematica agrees completely with the simulated values and not with the
funcValue. So I suspect it has something to do withfuncValue.$endgroup$
– JimB
Mar 21 at 15:14