Skip to main content
edited tags
Link
Routine cleanup
Source Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259

monte carlo Monte Carlo simulation using modified rejection technique

plot the probability density function

Plot the probability density function

w(x)=(1/(1+x^2))(1/x^0.5) for (0 < x < 1)

$\qquad w(x)=(1/(1+x^2))(1/x^{0.5})$ for $(0 < x < 1)$

make up the subroutine flowchart to get the random numbers x , using the modified rejection technique with first factor used as the comparison function use the flowchart to get a few random numbers in wolfram mathematica

Make up the subroutine flowchart to get the random numbers $x$, using the modified rejection technique with first factor used as the comparison function.

Use the flowchart to get a few random numbers in Wolfram Mathematica

trialTrial answer:

a = 0; b = 1;
f[x_] := (1/(1 + x^2)) * (1/x^0.5)
h = 1; Nt = 1000000;
gr1 = Plot[f[x], {x, a, b}] 

S := (
  x = y = b*h; 
  b h;  
  While[y > f[x], 
         x = a + (b - a)*RandomReal[]; 
    RandomReal[];  
    y = h*RandomReal[];
     h ];RandomReal[]]; 
      Return[x];
     ) 

rez = Table[S, {i, Nt}];
gr2 = Histogram[rez, Automatic, "PDF"]
Show[gr1, gr2]

monte carlo simulation using modified rejection technique

plot the probability density function

w(x)=(1/(1+x^2))(1/x^0.5) for (0 < x < 1)

make up the subroutine flowchart to get the random numbers x , using the modified rejection technique with first factor used as the comparison function use the flowchart to get a few random numbers in wolfram mathematica

trial answer:

a = 0; b = 1;
f[x_] := (1/(1 + x^2)) * (1/x^0.5)
h = 1; Nt = 1000000;
gr1 = Plot[f[x],{x, a, b}]
S := (x = y = b*h; 
      While[y > f[x], 
         x = a + (b - a)*RandomReal[]; 
         y = h*RandomReal[];
      ]; 
      Return[x];
     )
rez = Table[S, {i, Nt}];
gr2 = Histogram[rez, Automatic, "PDF"]
Show[gr1, gr2]

Monte Carlo simulation using modified rejection technique

Plot the probability density function

$\qquad w(x)=(1/(1+x^2))(1/x^{0.5})$ for $(0 < x < 1)$

Make up the subroutine flowchart to get the random numbers $x$, using the modified rejection technique with first factor used as the comparison function.

Use the flowchart to get a few random numbers in Wolfram Mathematica

Trial answer:

a = 0; b = 1;
f[x_] := (1/(1 + x^2)) (1/x^0.5)
h = 1; Nt = 1000000;
gr1 = Plot[f[x], {x, a, b}] 

S := (
  x = y = b h;  
  While[y > f[x], 
    x = a + (b - a) RandomReal[];  
    y = h RandomReal[]]; 
  Return[x];
) 

rez = Table[S, {i, Nt}];
gr2 = Histogram[rez, Automatic, "PDF"]
Show[gr1, gr2]
Formatted code, added tags
Source Link
MarcoB
  • 67.7k
  • 18
  • 96
  • 198

plot the probability density function

w(x)=(1/(1+x^2))(1/x^0.5) ,for (0<x<10 < x < 1)

make up the subroutine flowchart to get the random numbers x , using the modified rejection technique with first factor used as the comparison function use the flowchart to get a few random numbers in wolfram mathematica

trial answer:

a = 0; b = 1;
f[x_] := (1/(1 + x^2)) * (1/x^0.5)
h = 1; Nt = 1000000;
gr1 = Plot[f[x],{x, a, b}]
S := (x = y = b*h; 
      While[y > f[x], 
         x = a + (b - a)*RandomReal[]; 
         y = h*RandomReal[];
      ]; 
      Return[x];
     )
rez = Table[S, {i, Nt}];
gr2 = Histogram[rez, Automatic, "PDF"]
Show[gr1, gr2]

plot the probability density function

w(x)=(1/(1+x^2))(1/x^0.5) , (0<x<1)

make up the subroutine flowchart to get the random numbers x , using the modified rejection technique with first factor used as the comparison function use the flowchart to get a few random numbers in wolfram mathematica

trial answer:

a = 0; b = 1;
f[x_] := (1/(1 + x^2)) * (1/x^0.5)
h = 1; Nt = 1000000;
gr1 = Plot[f[x],{x, a, b}]
S := (x = y = b*h; 
      While[y > f[x], 
         x = a + (b - a)*RandomReal[]; 
         y = h*RandomReal[];
      ]; 
      Return[x];
     )
rez = Table[S, {i, Nt}];
gr2 = Histogram[rez, Automatic, "PDF"]
Show[gr1, gr2]

plot the probability density function

w(x)=(1/(1+x^2))(1/x^0.5) for (0 < x < 1)

make up the subroutine flowchart to get the random numbers x , using the modified rejection technique with first factor used as the comparison function use the flowchart to get a few random numbers in wolfram mathematica

trial answer:

a = 0; b = 1;
f[x_] := (1/(1 + x^2)) * (1/x^0.5)
h = 1; Nt = 1000000;
gr1 = Plot[f[x],{x, a, b}]
S := (x = y = b*h; 
      While[y > f[x], 
         x = a + (b - a)*RandomReal[]; 
         y = h*RandomReal[];
      ]; 
      Return[x];
     )
rez = Table[S, {i, Nt}];
gr2 = Histogram[rez, Automatic, "PDF"]
Show[gr1, gr2]
Formatted code, added tags
Source Link
MarcoB
  • 67.7k
  • 18
  • 96
  • 198
Loading
Source Link
Loading