The function ShowDigraphFractalsStochastic is similar, but uses a stochastic algorithm. Here the second argument refers to the total number of points generated and there is no Initiators option.
goldenAngle = 2 Pi (2 - GoldenRatio);
s1 = {.985^3 rotate[3 goldenAngle],{0,0}};
s2 = {{{.1,0},{0,.1}},{1,0}};
d1 = {{{.1,0},{0,.1}},.985 rotate[goldenAngle].{1,0}};
d2 = {{{.1,0},{0,.1}},.985^2 rotate[2 goldenAngle].{1,0}};
d3 = s1;
intertwinedSpirals = {{{s1},{s2}},{{d1,d2},{d3}}};
both = ShowDigraphFractalsStochastic[
intertwinedSpirals,30000,
DisplayFunction -> Identity];
Show[GraphicsArray[both]];
![[Graphics:../Images/index_gr_44.gif]](../Images/index_gr_44.gif)
These spirals look very nice when displayed together.
Show[both, DisplayFunction -> $DisplayFunction];
![[Graphics:../Images/index_gr_45.gif]](../Images/index_gr_45.gif)
Note that probabilities to generate a uniform distribution are automatically estimated. We may assign other probabilities using the option PMatrix. A basic understanding of the algorithm is necessary to use this option. We begin by assigning a positive probability
to every
such that for every
,
![]()
This simply means that the sum of all of the probabilities of all of the edges coming in to any particular node should be 1. For our matrix representation of the digraph, this means that the sum of all of the probabilities in any column should be 1. We then choose an arbitrary point
, an arbitrary vertex
, and some
according to our probability list {![]()
} and apply
to
. If
, this gives us a point
in our approximation to
, which then becomes our new input and the process continues. We are essentially performing a random walk along the digraph and picking up points as we go along. The edges are traversed in reverse order since
when
. Thus the option PMatrix will be a matrix of lists of numbers, with the same shape as the digraph, such that the sum of all of the probabilities in any column is 1. We may compute the PMatrix used by the package using the ComputePMatrix function. Here is the PMatrix for the previous example.
ComputePMatrix[intertwinedSpirals]
Let's see what happens if we fiddle with this a little.
both = ShowDigraphFractalsStochastic[
intertwinedSpirals,30000,
PMatrix -> {{{0.95},{0.15}},{{0.025,0.025},{0.85}}},
DisplayFunction -> Identity];
Show[GraphicsArray[both]];
![[Graphics:../Images/index_gr_63.gif]](../Images/index_gr_63.gif)
Show[both, DisplayFunction -> $DisplayFunction];
![[Graphics:../Images/index_gr_64.gif]](../Images/index_gr_64.gif)
The distribution has changed considerably. This trick was used by Barnsley to generate a non-uniform distribution on his fern, yielding a more natural look.
barnsleyFern = {{{
{{{.85,.04},{-.04,.85}},{0,1.6}},
{{{-.15,.28},{.26,.24}},{0,.44}},
{{{.2,-.26},{.23,.22}},{0,1.6}},
{{{0,0},{0,.16}},{0,0}}
}}};
ShowDigraphFractalsStochastic[barnsleyFern, 15000,
PMatrix -> {{ {.8, .09, .09, .02} }}];
![[Graphics:../Images/index_gr_65.gif]](../Images/index_gr_65.gif)