Permalink
Browse files

making accept reject algo an actual numbered example

  • Loading branch information...
1 parent b46588b commit 9c9ef3e8f67af4549e490ca99d09d50690782f5a @shiffman committed Jul 11, 2016
@@ -616,7 +616,7 @@
<pre data-code-language="java" data-type="programlisting" class="codesplit">
float r = random(1);
//{$3} A 1% chance of taking a large step
-if (r &lt; 0.01) {
+if (r < 0.01) {
xstep = random(-100, 100);
ystep = random(-100, 100);
} else {
@@ -660,7 +660,15 @@
<a data-primary="Monte Carlo method" data-type="indexterm"></a> <a data-primary="non-uniform distributions" data-secondary="Monte Carlo method" data-type="indexterm"></a> <a data-primary="distributions" data-secondary="non-uniform" data-tertiary="Monte Carlo method" data-type="indexterm"></a> <a data-primary="qualifying random values" data-secondary="Monte Carlo method" data-type="indexterm"></a>
-Here is a function (named for the accept-reject algorithm, a type ofMonte Carlo method, which was named for the Monte Carlo casino) that implements the above algorithm, returning a random value between 0 and 1.
+Here is a function (named for the accept-reject algorithm, a type of Monte Carlo method, which was named for the Monte Carlo casino) that implements the above algorithm, returning a random value between 0 and 1.
+
+<figure class="screenshot" data-pde="______"><img alt="intro ex05" src="intro/intro_ex05.png" />
+<figcaption>&nbsp;</figcaption>
+</figure>
+
+<div data-type="example">
+<h5>Example I.5: Accept-Reject distribution</h5>
+</div>
<pre data-code-language="java" data-type="programlisting" class="codesplit">
float acceptreject() {
@@ -865,12 +873,12 @@ <h2 id="noise-detail">Noise Detail</h2>
<p>We can apply the exact same logic to our random walker, and assign both its x- and y-values according to Perlin noise.</p>
-<figure class="screenshot" data-pde="processingjs/intro/_I_5_NoiseWalk/_I_5_NoiseWalk.pde processingjs/intro/_I_5_NoiseWalk/Walker.pde"><img alt="intro ex05" src="intro/intro_ex05.png" />
+<figure class="screenshot" data-pde="processingjs/intro/_I_5_NoiseWalk/_I_5_NoiseWalk.pde processingjs/intro/_I_5_NoiseWalk/Walker.pde"><img alt="intro ex06" src="intro/intro_ex06.png" />
<figcaption>&nbsp;</figcaption>
</figure>
<div data-type="example">
-<h5>Example I.5: Perlin noise walker</h5>
+<h5>Example I.6: Perlin noise walker</h5>
</div>
<pre data-code-language="java" data-type="programlisting" class="codesplit">
@@ -928,7 +936,7 @@ <h2 id="noise-detail">Noise Detail</h2>
<p>If you were to visualize this graph paper with each value mapped to the brightness of a color, you would get something that looks like clouds. White sits next to light gray, which sits next to gray, which sits next to dark gray, which sits next to black, which sits next to dark gray, etc.</p>
-<figure><img alt="intro ex06" src="intro/intro_ex06.png" />
+<figure><img alt="intro ex07" src="intro/intro_ex07.png" />
<figcaption>&nbsp;</figcaption>
</figure>
@@ -956,7 +964,7 @@ <h2 id="noise-detail">Noise Detail</h2>
<p>This is a nice start conceptually—it gives you a noise value for every (<span class="var">x</span>,<span class="var">y</span>) position in our two-dimensional space. The problem is that this won’t have the cloudy quality we want. Jumping from pixel 200 to pixel 201 is too large of a jump through noise. Remember, when we worked with one-dimensional noise, we incremented our time variable by 0.01 each frame, not by 1! A pretty good solution to this problem is to just use different variables for the noise arguments. For example, we could increment a variable called <span class="var">xoff</span> each time we move horizontally, and a <span class="var">yoff</span> variable each time we move vertically through the nested loops.</p>
<div data-type="example">
-<h5>Example I.6: 2D Perlin noise</h5>
+<h5>Example I.7: 2D Perlin noise</h5>
</div>
<pre data-code-language="java" data-type="programlisting" class="codesplit">
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9c9ef3e

Please sign in to comment.