I have the following function L:

σ = 9;
L[s_, d_] = (1/(σ*Sqrt[2*\[Pi]]))*E^(-(1/2)*((s-(-50-11*Log[d]))/σ)^2)

This function L describes basically for some specific d, the distribution of the random variable s. Therefore, for some fixed d value, the L[s] has the properties of a PDF. What I would like to do is find another function R[s_, d_] that does the opposite. That means, that for a fixed s value, the R[d] is the normalization version (normalized between [dmin, dmax]) of the corresponding L[d].

Any idea if this is even possible? Thank you for your time

σ = 9;
L[s_, d_] = (1/(σ*Sqrt[2*π]))*
   E^(-(1/2)*((s - (-50 - 11*Log[d]))/σ)^2);

The probability distribution is

dist[s_] = 
  ProbabilityDistribution[L[s, d], {d, 0, Infinity}, 
   Method -> "Normalize"];

r[s, d] is the PDF of the distribution

r[s_, d_] = PDF[dist[s], d]

enter image description here

Verifying the normalization,

Integrate[r[s, d], {d, 0, Infinity}]

(* 1 *)

The mean of the distribution is


(* E^(-(857/242) - s/11) *)

The variance of the distribution is


(* (-1 + E^(81/121)) E^(-(857/121) - (2 s)/11) *)

To generate random data from the distribution for a particular value of s:


data = RandomVariate[dist[1], 200];

 Histogram[data, Automatic, "PDF"],
 Plot[r[1, d], {d, 0, 0.12}]]

enter image description here

  • $\begingroup$ @Gouz This is why you shouldn't accept an answer too quickly. Here is a much better answer than I gave. You can change the accept. $\endgroup$ – JimB Apr 17 at 3:34

If the $d$ takes on values from 0 to $\infty$, then the normalizing constant is given by

Integrate[L[s, d], {d, 0, ∞}]
(* 1/11 E^(-(1019/242) - s/11) *)

So you could define the following function which is non-negative and integrates to 1 for a pdf associated with $d$:

r[s_, d_] := L[s, d]/(1/11 E^(-(1019/242) - s/11))

You should avoid using capital letters for functions you define.

  • $\begingroup$ Nice. May I ask, is it possible on Mathematica to show the Integration steps/process? $\endgroup$ – Gouz Apr 16 at 23:18
  • $\begingroup$ Use Rubi in Mathematica: rulebasedintegration.org to show steps. $\endgroup$ – JimB Apr 16 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.