File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 1083
1083
For our purposes, if we have PDF $p()$ and cumulative distribution function $P()$, we can use this
1084
1084
"inverse function" with a random number to get what we want:
1085
1085
1086
- $$ f(d) = P^{-1} (\operatorname{random_double }()) $$
1086
+ $$ f(d) = P^{-1} (\operatorname{random\_double }()) $$
1087
1087
1088
1088
For our PDF $p(r) = r/2$, and corresponding $P(r)$, we need to compute the inverse of $P(r)$. If we
1089
1089
have
1100
1100
1101
1101
Thus our random number generator with density $p(r)$ can be created with:
1102
1102
1103
- $$ f(d) = \sqrt{4\cdot\operatorname{random_double }()} $$
1103
+ $$ f(d) = \sqrt{4 \cdot \operatorname{random\_double }()} $$
1104
1104
1105
1105
Note that this ranges from 0 to 2 as we hoped, and if we check our work, we replace
1106
1106
`random_double()` with $1/4$ to get 1, and also replace with $1/2$ to get $\sqrt{2}$, just as
2154
2154
cross product that $\mathbf{n} \times \mathbf{a}$ is perpendicular to both $\mathbf{n}$ and
2155
2155
$\mathbf{a}$:
2156
2156
2157
- $$ \mathbf{s} = \operatorname{unit_vector }(\mathbf{n} \times \mathbf{a}) $$
2157
+ $$ \mathbf{s} = \operatorname{unit\_vector }(\mathbf{n} \times \mathbf{a}) $$
2158
2158
2159
2159
$$ \mathbf{t} = \mathbf{n} \times \mathbf{s} $$
2160
2160
You can’t perform that action at this time.
0 commit comments