<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel rdf:about="https://community.wolfram.com">
    <title>Community RSS Feed</title>
    <link>https://community.wolfram.com</link>
    <description>RSS Feed for Wolfram Community showing any discussions tagged with Wolfram Science sorted by most viewed.</description>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/326240" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/122095" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/995095" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/404292" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/114911" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/235291" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/526743" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/121507" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/108323" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/133271" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/227651" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/863933" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/33771" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/546818" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1065956" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/392391" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/595870" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/946991" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/897811" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/603607" />
      </rdf:Seq>
    </items>
  </channel>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/326240">
    <title>Simulating a global Ebola outbreak</title>
    <link>https://community.wolfram.com/groups/-/m/t/326240</link>
    <description>Triggered by the recent outbreak of Ebola India Bruckner, a pupil from Aberdeen&amp;#039;s [St Margaret&amp;#039;s School for Girls][1], and myself worked on a little model this summer to understand the basics of the spreading of diseases in populations and the relationship to transportation networks. The model is very basic, but shows some interesting features and is very straight forward to implement in Mathematica. &#xD;
&#xD;
When I was typing these lines I saw that Arnoud Buzing had posted something, reason enough to interrupt my typing and to check out what he had posted: [Visualizing the Ebola Outbreak][2]. I hope that my post is going to complement Arnoud&amp;#039;s to some extent.&#xD;
&#xD;
So, my question is how the global air transport network might lead to a spreading of a disease. I will use a very standard SIR (susceptible-infected-recovered) model, which is certainly far from being ideal for Ebola; [but similar types of models are to too bad either][3]. It rather simulates an outbreak of some generic disease from which you recover. If we assumed that everyone died in an outbreak the SIR model might also be appropriate. I will introduce the equations below. I also need a list of all airports and all flight connections. On the website [Openflights.org][4] you will find all data we need. I saved the file &amp;#034;airports.dat&amp;#034; and the file &amp;#034;routes.dat&amp;#034;. So that&amp;#039;s the data. &#xD;
&#xD;
I first import the data:&#xD;
&#xD;
    airports = Import[&amp;#034;~/Desktop/airports.dat&amp;#034;, &amp;#034;CSV&amp;#034;];&#xD;
    routes = Import[&amp;#034;~/Desktop/routes.dat&amp;#034;, &amp;#034;CSV&amp;#034;];&#xD;
&#xD;
This is a plot of all airports in that database.&#xD;
&#xD;
    GeoRegionValuePlot[Table[GeoPosition[airports[[i, {7, 8}]]] -&amp;gt; 1., {i, 1, Length[airports]}], PlotStyle -&amp;gt; PointSize[0.003], PlotRange -&amp;gt; 1, ImageSize -&amp;gt; Full]&#xD;
&#xD;
which gives&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
Alright, now the routes. First, we create a list of rules for all airport IDs and their coordinates:&#xD;
&#xD;
    codecoords = Table[airports[[i, 5]] -&amp;gt; GeoPosition[airports[[i, {7, 8}]]], {i, 1,Length[airports]}];&#xD;
&#xD;
We then calculate the links:&#xD;
&#xD;
    links = Monitor[Table[routes[[j, {3, 5}]] /. codecoords, {j, 1, Length[routes]}], ProgressIndicator[j, {1, Length[routes]}]];&#xD;
&#xD;
and clean out missing data:&#xD;
&#xD;
    linksclean = Select[links, Head[#[[1]]] == GeoPosition &amp;amp;&amp;amp; Head[#[[2]]] == GeoPosition &amp;amp;];&#xD;
&#xD;
Now comes a nice figure:&#xD;
&#xD;
    With[{locations = RandomChoice[linksclean, 14000]}, GeoGraphics[{{Green, Opacity[0.3],AbsoluteThickness[0.0001], GeoPath[locations, &amp;#034;Geodesic&amp;#034;]}}, &#xD;
      GeoRange -&amp;gt; &amp;#034;World&amp;#034;, GeoProjection -&amp;gt; Automatic, GeoBackground -&amp;gt; GeoStyling[&amp;#034;ReliefMap&amp;#034;], ImageSize -&amp;gt; {1200, 600}]]&#xD;
&#xD;
which gives&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
Ok. Interestingly I can only plot 16000 max at a time. Somewhere between 16-17k the Kernel quits. That might be Integer related. Could be a limit in the programming of Geographics. Not sure. I have more than enough memory and can plot the remaining 2-3k airports in a second figure and use Show to display all. (It would be great if someone from WRI could comment.)&#xD;
&#xD;
Anyway, let&amp;#039;s go to some modelling. The basic idea of an [SIR model][7] is that a population is modelled in three compartments Susceptibles (S), Infected (I) and Recovered (R). I will use a time-discrete model; there are continuous models around, too, and if anyone is interested I can provide the ODE model as well. Here are the three equations:&#xD;
&#xD;
    sus[i_] := sus[i] = sus[i - 1] - [Rho] sus[i - 1] inf[i - 1];&#xD;
    inf[i_] := nf[i] = inf[i - 1] + [Rho] sus[i - 1] inf[i - 1] - [Lambda] inf[i - 1];&#xD;
    rec[i_] := rec[i] = rec[i - 1] + [Lambda] inf[i - 1];&#xD;
&#xD;
The meaning of sus, inf and rec should be clear by now; they are given as percentages of the total population, their sum is 100%. The variable i represents time. $&#xD;
ho$ is an infection rate and $lambda$ is a recovery rate. The infections increase with the product of susceptibles and infected. By adding the right hand sides it becomes clear that the population does not change over time. We come up with some values for the parameters and iterate:&#xD;
&#xD;
    sus[1] = 0.95; inf[1] = 0.05; rec[1] = 0; [Rho] = 0.2; [Lambda] = 0.1;&#xD;
    tcourse = Table[{sus[i], inf[i], rec[i]}, {i, 1, 100}];&#xD;
&#xD;
The time course looks like this:&#xD;
&#xD;
    ListPlot[Transpose[tcourse]]&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
The monotonously decreasing function show susceptibles, the increasing function recovered, and the remaining curve the infected. We now need to do some cleaning up of the original airport data, before we proceed to a multi-airport/city model. &#xD;
&#xD;
    (*Extract the names and GPS coordinates*)&#xD;
    &#xD;
    rawdata = &#xD;
      Sort[Select[airports[[All, {5, 7, 8}]], #[[1]] != &amp;#034;&amp;#034; &amp;amp;]][[81 ;;]];&#xD;
    &#xD;
    (*These are just the coordinates*)&#xD;
    &#xD;
    airportcoords = rawdata[[All, {2, 3}]];&#xD;
    &#xD;
    (*These are just the names. *)&#xD;
    &#xD;
    names = rawdata[[All, 1]];&#xD;
    &#xD;
    (*Here are the names to indices*)&#xD;
    &#xD;
    rules = MapThread[#1 -&amp;gt; #2 &amp;amp;, {names, Range[Length[names]]}];&#xD;
    &#xD;
    (*The &amp;#034;population&amp;#034; is initially set to 1 for all airports, this allows us to take different airport sizes into consideration later.*)&#xD;
    &#xD;
    pop = Table[1., {j, 1, Length[names]}]; &#xD;
    routesraw = Import[&amp;#034;~/Desktop/routes.dat&amp;#034;, &amp;#034;CSV&amp;#034;];&#xD;
    &#xD;
    (*There are many links so this takes a while*)&#xD;
    &#xD;
    links = Select[routesraw[[All, {3, 5}]] /. rules, NumberQ[#[[1]]] &amp;amp;&amp;amp; NumberQ[#[[2]]] &amp;amp;];&#xD;
&#xD;
From that we now construct (a first guess at) the coupling or adjacency matrix:&#xD;
&#xD;
    couplingdummy = Table[0, {i, 1, Length[names]}, {j, 1, Length[names]}];&#xD;
    &#xD;
    For[k = 1, k &amp;lt;= Length[links], k++, &#xD;
      couplingdummy[[links[[k, 1]], links[[k, 2]]]] = 1; &#xD;
      couplingdummy[[links[[k, 2]], links[[k, 1]]]] = 1];&#xD;
&#xD;
I do know about ConstantArray, but for some reason that does not work. The first line constructs a matrix full of zeros and the second adds ones where there are links. The problem is that apparently in that dataset some airports are not linked at all. We can sort them out by:&#xD;
&#xD;
    indices = Select[Table[If[Total[couplingdummy[[i]]] &amp;gt; 0, i], {i, 1, Length[couplingdummy]}], NumberQ];&#xD;
&#xD;
We now delete the columns and rows of the couplingdummy matrix&#xD;
&#xD;
    intermed = couplingdummy[[#]] &amp;amp; /@ indices;&#xD;
    transintermed = Transpose[intermed];&#xD;
    coupling = transintermed[[#]] &amp;amp; /@ indices;&#xD;
&#xD;
Again I had a much more elegant way of doing this, with the advantage that it did not work. To speed up the following calculations I use that the coupling matrix is sparse, but I like the original too much to throw it away just yet. &#xD;
&#xD;
    coulinginterm = coupling;&#xD;
    coupling = SparseArray[coulinginterm];&#xD;
&#xD;
We adapt our &amp;#034;population/airport size&amp;#034; vector:&#xD;
&#xD;
    pop = Table[1., {j, 1, Length[indices]}]; &#xD;
&#xD;
and set the following parameters:&#xD;
&#xD;
    [Rho] = 0.2; [Lambda] = 0.1; Mairports =  Length[indices]; [Mu] = 0.05;&#xD;
&#xD;
$\rho$ and $lambda$ are as before. Mairports is the number of airports that we model and $\mu$ is a &amp;#034;migration rate&amp;#034;. It comes from the original model which we built for different cities were it describes the migration between different cities. Here is models the &amp;#034;propensity to fly&amp;#034;. &#xD;
&#xD;
We now define an effective coupling matrix. It is the adjacency matrix times the population vector (i.e. people in the catchment area of the airport). In our case the vector has all ones, so it is just the adjacency matrix. It allows us later to model more general situations. &#xD;
&#xD;
    meanNN = coupling.pop;&#xD;
&#xD;
When we want to model the outbreak as populations at the positions of all airports, each of which is described by an SIR model, we need to couple lots of populations, because there are lots of airports. The following uses the sparsity of the adjacency matrix to speed up the calculation. &#xD;
&#xD;
    sumind = Table[Take[Flatten[ArrayRules[coupling[[k, All]]][[All, 1]]], Length[ArrayRules[coupling[[k, All]]]] - 1], {k, 1, Mairports}];&#xD;
&#xD;
It generates a list of all airports that are coupled/linked to a given airport. Now we are ready to write down the central equations:&#xD;
&#xD;
    sus[i_, j_] :=  sus[i, j] = (1 - [Mu]) (sus[i - 1, j] - [Rho] sus[i - 1, j] inf[i - 1, j]) + [Mu]  Total[Table[sus[i - 1, sumind[[j, u]]]*pop[[sumind[[j, u]]]], {u, 1, Length[sumind[[j]]]} ] ]/meanNN[[j]]; &#xD;
    inf[i_, j_] := inf[i, j] = (1 - [Mu]) (inf[i - 1, j] + [Rho] sus[i - 1, j] inf[i - 1, j] - [Lambda] inf[i - 1, j]) + [Mu] Total[Table[inf[i - 1, sumind[[j, u]]]*pop[[sumind[[j, u]]]], {u, 1, Length[sumind[[j]]]} ] ]/meanNN[[j]];&#xD;
    rec[i_, j_] := rec[i, j] = (1 - [Mu]) (rec[i - 1, j] + [Lambda] inf[i - 1, j]) + [Mu] Total[Table[rec[i - 1, sumind[[j, u]]]*pop[[sumind[[j, u]]]], {u, 1,Length[sumind[[j]]]} ] ]/meanNN[[j]];&#xD;
&#xD;
The terms with the Total are &amp;#034;migration terms&amp;#034; that describe the travelling behaviour of the people in the catchment area of the airports. i is the time index and j labels the airports. Next come the initial conditions:&#xD;
&#xD;
    For[i = 1, i &amp;lt;= Mairports, i++, sus[1, i] = 1.; inf[1, i] = 0.0;  rec[1, i] = 0.;]&#xD;
    sus[1, 1] = 0.95; &#xD;
    inf[1, 1] = 0.05;&#xD;
    rec[1, 1] = 0.0;&#xD;
&#xD;
In the catchment areas of all airports there are only susceptibles, apart from airport number 1, which will have 5% infected people. Now we can finally iterate the whole thing:&#xD;
&#xD;
    tcourse = Monitor[Table[{sus[i, j], inf[i, j], rec[i, j]}, {i, 1, 500}, {j, 1,Mairports}], ProgressIndicator[i, {0, 500}]];&#xD;
&#xD;
Great. Let&amp;#039;s save that just in case your notebook tends to crash at this point, just l like mine did when I was playing with this.&#xD;
&#xD;
    Export[&amp;#034;~/Desktop/SIR-tcourse.csv&amp;#034;, tcourse];&#xD;
&#xD;
If you wish you can now plot the time course of some of the airport catchment areas:&#xD;
&#xD;
    ListPlot[Flatten[Table[{tcourse[[All, j, 1]], tcourse[[All, j, 2]], tcourse[[All, j, 3]]}, {j, 1, 200}], 1], ImageSize -&amp;gt; Large]&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
Now that is not very helpful yet. To generate nicer plots, i.e. to normalise, we first calculate the maximal number of sick  people at any of the airports:&#xD;
&#xD;
    maxsick = Max[Flatten[tcourse[[All, All, 2]]]];&#xD;
&#xD;
We then generate movie frames, and go and get some coffee....&#xD;
&#xD;
    frames = Monitor[Table[GeoRegionValuePlot[Table[GeoPosition[airportcoords[[indices[[i]]]]] -&amp;gt; inf[k, i]/maxsick, {i, 1, Length[indices]}], PlotStyle -&amp;gt; PointSize[0.003], PlotRange -&amp;gt; 1, ImageSize -&amp;gt; Full,ColorFunction -&amp;gt; &amp;#034;Rainbow&amp;#034;], {k, 1, 300}], ProgressIndicator[k, {0, 300}]];&#xD;
&#xD;
Actually, you might want to get another coffee when you want to export the frames:&#xD;
&#xD;
    Export[&amp;#034;~/Desktop/SIR-frames-World.gif&amp;#034;, frames];&#xD;
&#xD;
Alright. That gif is a bit large to embed it into this post, but you can download it from [here][10]. All I can do is show you some frames to get an idea of how this looks:&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
Of course we can look at the network structure and try to understand the pattern of infections. This command is useful:&#xD;
&#xD;
    CommunityGraphPlot[AdjacencyGraph[Normal[coupling]]]&#xD;
&#xD;
![enter image description here][12]&#xD;
&#xD;
You clearly see the communities in North America, Europe and Asia. This one is also pretty:&#xD;
&#xD;
    Show[TreePlot[Subgraph[grph, ConnectedComponents[grph][[1]]], Center, PlotStyle -&amp;gt; Directive[Gray, Opacity[0.02]]], &#xD;
     TreePlot[Subgraph[grph, ConnectedComponents[grph][[1]]], Center, EdgeRenderingFunction -&amp;gt; None]]&#xD;
&#xD;
![enter image description here][13]&#xD;
&#xD;
We have several enhancements of this. First we can easily look at different countries individually. What if an ebola patient arrives at some airport in the US? [See simulation here][14]. (Careful 50 MBs!)&#xD;
&#xD;
There is also something we can do if we want to go the the level of cities. The main problem is that the Wolfram database does not yet have data for all streets between cities. In one of the online conferences it was said that that will be introduced in some later version, which I cannot wait to play with. Until then we have to cheat. (or use some online database; I prefer cheating.)&#xD;
&#xD;
We developed a model of the spreading of a disease in Nigeria. So we could go about this like this:&#xD;
&#xD;
    Clear[&amp;#034;Global`*&amp;#034;]&#xD;
    CountryData[&amp;#034;Nigeria&amp;#034;, &amp;#034;Population&amp;#034;]&#xD;
    Graphics[CountryData[&amp;#034;Nigeria&amp;#034;, &amp;#034;Polygon&amp;#034;]] &#xD;
&#xD;
Then get city names, coords and population:&#xD;
&#xD;
    names = CityData[{All, &amp;#034;Nigeria&amp;#034;}];&#xD;
    citypop = Table[CityData[names[[i]], &amp;#034;Population&amp;#034;], {i, 1, Length[names]}];&#xD;
    citycoords = Table[CityData[names[[i]], &amp;#034;Coordinates&amp;#034;], {i, 1, Length[names]}];&#xD;
&#xD;
Here comes the cheat. Because we don&amp;#039;t have the streets we use Delaunay triangulation:&#xD;
&#xD;
    Needs[&amp;#034;ComputationalGeometry`&amp;#034;]&#xD;
    dtri = DelaunayTriangulation[citycoords]; list = {}; Table[&#xD;
     Do[AppendTo[list, {i, dtri[[All, 2]][[i, j]]}], {j, 1, &#xD;
       Length[dtri[[All, 2]][[i, All]]]}], {i, 1, Length[dtri]}];&#xD;
    coupling = Table[0, {i, 1, Length[names]}, {j, 1, Length[names]}];&#xD;
    For[i = 1, i &amp;lt; Length[list] + 1, i++, &#xD;
     coupling[[list[[i]][[1]], list[[i]][[2]]]] = 1;]&#xD;
    &#xD;
    coulinginterm = coupling;&#xD;
    &#xD;
    coupling = SparseArray[coulinginterm];&#xD;
&#xD;
which gives the following network&#xD;
&#xD;
    Graphics[Join[&#xD;
      Table[Circle[citycoords[[i]], 0.02], {i, 1, Length[names]}], &#xD;
      DeleteCases[&#xD;
       Flatten[Table[&#xD;
         If[coupling[[i, j]] == 1, &#xD;
          Line[{citycoords[[i]], citycoords[[j]]}]] , {i, 1, &#xD;
          Length[names]}, {j, 1, i}], 1], Null]]]&#xD;
&#xD;
![enter image description here][15]&#xD;
&#xD;
The point in the middle corresponds to the airport where it all starts; then come its neighbours and then their neighbours etc. You could now animate this and change the colours to see how the disease spreads through the different layers. It would be nice if someone could implement that. &#xD;
&#xD;
There are obviously some problems, i.e. &amp;#034;streets&amp;#034; leaving the country etc, but the general idea should work. The rest is quite the same as before:&#xD;
&#xD;
    (*Paramters*)&#xD;
    &#xD;
    [Rho] = 0.2; [Lambda] = 0.1; Mcities = Length[names]; [Mu] = 0.05;&#xD;
    &#xD;
    (*Initiation*)&#xD;
    &#xD;
    For[i = 1, i &amp;lt;= Mcities, i++, sus[1, i] = 1.; inf[1, i] = 0.0; &#xD;
     rec[1, i] = 0.;]&#xD;
    &#xD;
    (*Starting Outbrake at the following city*)&#xD;
    &#xD;
    sus[1, 1] = 0.95; inf[1, 1] = 0.05;&#xD;
    rec[1, 1] = 0.0;&#xD;
    &#xD;
    meanNN = coupling.citypop;&#xD;
    &#xD;
    sumind = Table[&#xD;
       Take[Flatten[ArrayRules[coupling[[k, All]]][[All, 1]]], &#xD;
        Length[ArrayRules[coupling[[k, All]]]] - 1], {k, 1, Mcities}];&#xD;
    &#xD;
    sus[i_, j_] := &#xD;
     sus[i, j] = (1 - [Mu]) (sus[i - 1, &#xD;
           j] - [Rho] sus[i - 1, j] inf[i - 1, j]) + [Mu]  Total[&#xD;
          Table[sus[i - 1, sumind[[j, u]]]*citypop[[sumind[[j, u]]]], {u, &#xD;
            1, Length[sumind[[j]]]} ] ]/meanNN[[j]]; &#xD;
    inf[i_, j_] := &#xD;
     inf[i, j] = (1 - [Mu]) (inf[i - 1, &#xD;
           j] + [Rho] sus[i - 1, j] inf[i - 1, j] - [Lambda] inf[i - 1, &#xD;
            j]) + [Mu] Total[&#xD;
          Table[inf[i - 1, sumind[[j, u]]]*citypop[[sumind[[j, u]]]], {u, &#xD;
            1, Length[sumind[[j]]]} ] ]/meanNN[[j]];&#xD;
    rec[i_, j_] := &#xD;
      rec[i, j] = (1 - [Mu]) (rec[i - 1, &#xD;
            j] + [Lambda] inf[i - 1, j]) + [Mu] Total[&#xD;
           Table[rec[i - 1, sumind[[j, u]]]*citypop[[sumind[[j, u]]]], {u,&#xD;
              1, Length[sumind[[j]]]} ] ]/meanNN[[j]];&#xD;
&#xD;
This time we try to work in parallel:&#xD;
&#xD;
    LaunchKernels[];&#xD;
    tcourse = ParallelTable[{sus[i, j], inf[i, j], rec[i, j]}, {i, 1, 500}, {j, 1, Mcities}]; // AbsoluteTiming&#xD;
&#xD;
(There is something strange here. This ran in MMA9 in 6.3 seconds- I still have data from the course I taught last year. MMA10 takes ages. After the installation of MMA10 also MMA9 seems to take longer 43 seconds. Is this a bug report?). Note that this time the population sizes of the cities are taken into account and are relevant. If you run&#xD;
&#xD;
    Manipulate[&#xD;
     Graphics[{Line[Flatten[CountryData[&amp;#034;Nigeria&amp;#034;, &amp;#034;Coordinates&amp;#034;], 1]], &#xD;
       Join[Table[{ &#xD;
          RGBColor[tcourse[[t, i, 2]], tcourse[[t, i, 1]], &#xD;
           tcourse[[t, i, 3]]], Disk[citycoords[[i]], 0.1]}, {i, 1, &#xD;
          Length[names]}]]}], {t, 1, 500, 1}]&#xD;
&#xD;
or &#xD;
&#xD;
    poly = Graphics[Polygon[Flatten[CountryData[&amp;#034;Nigeria&amp;#034;, &amp;#034;Coordinates&amp;#034;], 1]], ImagePadding -&amp;gt; None];&#xD;
    Animate[ImageSubtract[&#xD;
      Graphics[ListDensityPlot[&#xD;
        Join[{{4, 3.25, 0}, {4, 14, 0}, {14, 3.25, 0}, {14, 14, 0}}, &#xD;
         Table[{citycoords[[k]][[1]], citycoords[[k]][[2]], &#xD;
           1. - tcourse[[t, k, 1]]}, {k, 1, Mcities}]], &#xD;
        InterpolationOrder -&amp;gt; 3, ColorFunction -&amp;gt; &amp;#034;Rainbow&amp;#034;, &#xD;
        PlotRange -&amp;gt; All, Frame -&amp;gt; False, PlotRangePadding -&amp;gt; None]], &#xD;
      poly], {t, 1, 500, 1}, DefaultDuration -&amp;gt; 20.]&#xD;
&#xD;
or better &#xD;
 &#xD;
&#xD;
    infmax = Max[tcourse[[All, All, 2]]];&#xD;
    frames = Table[&#xD;
       ImageSubtract[&#xD;
        Graphics[&#xD;
         ListDensityPlot[&#xD;
          Join[{{4, 3.25, 0}, {4, 14, 0}, {14, 3.25, 0}, {14, 14, 0}}, &#xD;
           Table[{citycoords[[k]][[1]], citycoords[[k]][[2]], &#xD;
             tcourse[[t, k, 2]]/infmax}, {k, 1, Mcities}]], &#xD;
          InterpolationOrder -&amp;gt; 3, ColorFunction -&amp;gt; &amp;#034;Rainbow&amp;#034;, &#xD;
          PlotRange -&amp;gt; All, Frame -&amp;gt; False, PlotRangePadding -&amp;gt; None, &#xD;
          ColorFunctionScaling -&amp;gt; False]], poly], {t, 1, 500, 6}];&#xD;
&#xD;
you get nice animations like this one:&#xD;
&#xD;
![enter image description here][16]&#xD;
&#xD;
I have noticed that Nigeria needs to be rotated, but I hope that the idea becomes clear. I am also aware that there are many flaws in this. SIR is certainly not the best way forward to model Ebola. Any population dynamicist and/or health expert can certainly come up with an endless list of problems. The network is not perfect. For more serious applications we actually use models for the cities, i.e. street connections among close cities and airport connections among countries etc. The problem is that if we simulate between 200-20000  cities per country plus the airports, a standard laptop runs into trouble. On the bright side, we have a cluster on which this kind of larger simulations work just fine. &#xD;
&#xD;
Hope that you like this anyway,&#xD;
&#xD;
Marco&#xD;
&#xD;
&#xD;
  [1]: http://www.st-margaret.aberdeen.sch.uk&#xD;
  [2]: http://community.wolfram.com/groups/-/m/t/325956&#xD;
  [3]: http://mtbi.asu.edu/files/Mathematical_Models_to_Study_the_Outbreaks_of_Ebola.pdf&#xD;
  [4]: http://openflights.org/data.html&#xD;
  [5]: /c/portal/getImageAttachment?filename=Airportsall.jpg&amp;amp;userId=48754&#xD;
  [6]: /c/portal/getImageAttachment?filename=Airports-world.jpg&amp;amp;userId=48754&#xD;
  [7]: http://en.wikipedia.org/wiki/Compartmental_models_in_epidemiology&#xD;
  [8]: /c/portal/getImageAttachment?filename=SingleSIR.jpg&amp;amp;userId=48754&#xD;
  [9]: /c/portal/getImageAttachment?filename=SIR-airportstcourse.jpg&amp;amp;userId=48754&#xD;
  [10]: https://www.dropbox.com/s/9y6d16z82qjw261/SIR-frames.gif?dl=0&#xD;
  [11]: /c/portal/getImageAttachment?filename=SIR-airports-frames.jpg&amp;amp;userId=48754&#xD;
  [12]: /c/portal/getImageAttachment?filename=Airports-CommNetwork.jpg&amp;amp;userId=48754&#xD;
  [13]: /c/portal/getImageAttachment?filename=SIR-networkrings.jpg&amp;amp;userId=48754&#xD;
  [14]: https://www.dropbox.com/s/0qwgmi7ks8dpsjh/SIR-USA-frames.gif?dl=0&#xD;
  [15]: /c/portal/getImageAttachment?filename=SIR-Nigerianetwork.jpg&amp;amp;userId=48754&#xD;
  [16]: /c/portal/getImageAttachment?filename=SIR-movie.gif&amp;amp;userId=48754</description>
    <dc:creator>Marco Thiel</dc:creator>
    <dc:date>2014-08-22T20:18:58Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/122095">
    <title>Dancing with friends and enemies: boids&amp;#039; swarm intelligence</title>
    <link>https://community.wolfram.com/groups/-/m/t/122095</link>
    <description>The latest way I have found to use my expensive math software for frivolous entertainment is this. Here&amp;#039;s is a way to describe it. 
[list]
[*]1000 dancers assume random positions on the dance-floor. 
[*]Each randomly chooses one &amp;#034;friend&amp;#034; and one &amp;#034;enemy&amp;#034;. 
[*]At each step every dancer 
[list]
[*]moves 0.5% closer to the centre of the floor
[*]then takes a large step towards their friend 
[*]and a small step away from their enemy. 
[/list]
[*]At random intervals one dancer re-chooses their friend and enemy
[/list]
Randomness is deliberately injected. Here is the dance...
[mcode]n = 1000; 
r := RandomInteger[{1, n}]; 
f := (#/(.01 + Sqrt[#.#])) &amp;amp; /@ (x[[#]] - x) &amp;amp;; 
s := With[{r1 = r}, p[[r1]] = r; q[[r1]] = r]; 
x = RandomReal[{-1, 1}, {n, 2}]; 
{p, q} = RandomInteger[{1, n}, {2, n}]; 
Graphics[{PointSize[0.007], Dynamic[If[r &amp;lt; 100, s]; 
Point[x = 0.995 x + 0.02 f[p] - 0.01 f[q]]]}, PlotRange -&amp;gt; 2][/mcode]
[img]/c/portal/getImageAttachment?filename=OPTfnlfrnds.gif&amp;amp;userId=11733[/img]

Thanks to Vitaliy for posting this on my behalf, complete with animations :-)

Background: I had read somewhere that  macro-scale behaviour of animal swarms (think of flocks of starlings or shoals of herring) is explained by each individual following very simple rules local to their vicinity, essentially 1) try to keep up and 2) try not to collide. I started trying to play with this idea in Mathematica, but it was rather slow to identify the nearest neighbours of each particle. So I wondered what would happen if each particle acted according to the locations of two other particles, regardless of their proximity. The rule was simply to move away from one and towards the other.

The contraction (x = 0.995 x) was added to prevent the particle cloud from dispersing towards infinity or drifting away from the origin. I tweaked the &amp;#034;towards&amp;#034; and &amp;#034;away&amp;#034; step sizes to strike a balance between the tendency to clump together and to spread apart (if you make the step sizes equal you get something more like a swarm of flies). With each particle&amp;#039;s attractor and repeller fixed, the system finds a sort of dynamic equilibrium, so to keep things changing I added a rule to periodically change the attractor and repeller for one of the particles. The final adjustment was to make the &amp;#034;force&amp;#034; drop towards zero for particles at very close range. This helps to stop the formation of very tight clumps, and also prevents a division-by-zero error when a particle chooses itself as its attractor or repeller.

The description of the system as a dance was an attempt to explain the swirling pattern on the screen without using mathematical language. I&amp;#039;d love to see what other &amp;#034;dances&amp;#034; can be created with other simple rules.</description>
    <dc:creator>Simon Woods</dc:creator>
    <dc:date>2013-09-11T18:31:12Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/995095">
    <title>How many animals can one find in a random image?</title>
    <link>https://community.wolfram.com/groups/-/m/t/995095</link>
    <description>![enter image description here][18]&#xD;
&#xD;
The long evolutionary history of humans has optimized the recognition of animals in the human vision system. To escape predators and to find food. Sometimes we believe to see animals and human faces, even if there aren&amp;#039;t any, this phenomena is called [pareidolia][1], or more generally apophenia. Classic examples are Jesus on a toast ([Liu2014][2]), the image on the shroud of Turin ([Sheen2016][3]), Elvis in a potato chip ([Voss2011][4]), and the face on Mars ([Martinez-Conde2012][5]).  In many cases, in about 100ms ([Naber2012][6]) humans can identify animal shapes. Some animals, e.g. snakes are potentially identified much faster ([VanLe2013][7]).&#xD;
&#xD;
So, an interesting question might be: how often do we (believe to) see animals in an genuinely random image?&#xD;
&#xD;
Here is, in the literal sense of the word, a random image of size 300*300 pixels:&#xD;
&#xD;
    SeedRandom[4056380]; &#xD;
    dim=300;&#xD;
    randomImage = Image[Table[RandomChoice[{2,1}-&amp;gt;{0,1}],{dim},{dim}]];&#xD;
    Show[randomImage,ImageSize -&amp;gt; 300]&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
No animal shapes are directly visible.&#xD;
&#xD;
Using ImageMesh we can get the individual/connected components (some potentially animal-like shaped) as regions (this operation is not fully deterministic, so results below may vary).&#xD;
&#xD;
    Show[imesh=ImageMesh[randomImage,Method-&amp;gt;&amp;#034;DualMarchingSquares&amp;#034;],ImageSize -&amp;gt; 300]&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
These are the individual shapes. We ignore too small and too large regions. For our image we find neatly 400 regions.&#xD;
&#xD;
    (* this takes a minute *)&#xD;
    shapes=Select[ConnectedMeshComponents@imesh,18&amp;lt; Area[#]&amp;lt;2000&amp;amp;];&#xD;
    Length[shapes]&#xD;
&#xD;
`393`&#xD;
&#xD;
These are the shapes positioned in the original image.&#xD;
&#xD;
    Show[HighlightMesh[#,Style[2, RandomColor[]]]&amp;amp;/@ shapes]&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
For later use, we define one function to make a random image and get the shapes.&#xD;
&#xD;
    getShapes[{black_,white_}, dim_] :=Select[ConnectedMeshComponents@&#xD;
    ImageMesh[Image[Table[RandomChoice[{black,white}-&amp;gt;{0,1}],{dim},{dim}]],&#xD;
    Method-&amp;gt;&amp;#034;DualMarchingSquares&amp;#034;],18&amp;lt; Area[#]&amp;lt;2000&amp;amp;]&#xD;
&#xD;
As we want to interpret the shapes as animals, we smooth the edges. We switch from regions to graphics.&#xD;
&#xD;
    smooth[reg_] :=Graphics[{Lighter[Blue], &#xD;
    (ToExpression[ToString[InputForm@reg],StandardForm,Hold] /.&#xD;
    HoldPattern[BoundaryMeshRegion[v_,b__,___Rule]]:&amp;gt;GraphicsComplex[v,FilledCurve[{b}/.&#xD;
    Line[l_]:&amp;gt; BSplineCurve[DeleteDuplicates[Flatten[l,1]],&#xD;
    SplineClosed-&amp;gt;True,SplineDegree-&amp;gt;2]]])[[1]]}]&#xD;
&#xD;
We also allow changing the orientation and color.&#xD;
&#xD;
    rotate[g_,?_] := With[{m={{Cos[?],Sin[?]},{-Sin[?], Cos[?]}}},g/.&#xD;
    GraphicsComplex[v_, r__]:&amp;gt; GraphicsComplex[m.#&amp;amp;/@ v,r]]&#xD;
    &#xD;
    flip[g_] := g/.GraphicsComplex[v_, r__]:&amp;gt; GraphicsComplex[{-1,1}#&amp;amp;/@ v,r]&#xD;
    &#xD;
    recolor[g_,col_] := g/.c_RGBColor:&amp;gt;col&#xD;
    &#xD;
    animalize[g_,{f_,?_,col_}] := Graphics[ recolor[rotate[If[f, flip,Identity]@&#xD;
    smooth[g],?],col], PlotRange -&amp;gt; All]&amp;amp;[smooth[g]]&#xD;
&#xD;
Here are some of the shapes that were hiding in the above image.The human eye tries to see fishes, wales, birds, squirrels, frogs, ducks, sea-horses, bunnies, deers, dogs, cats and similar creatures as well as human heads.&#xD;
&#xD;
    GraphicsGrid[Partition[Show[#, ImageSize -&amp;gt; 120,Frame-&amp;gt;True,FrameTicks-&amp;gt;False]&amp;amp;/@#,5]&amp;amp;@&#xD;
    { animalize[shapes[[18]],{False,1.8,GrayLevel[0.1]}],&#xD;
      animalize[shapes[[99]],{False,1.1,Darker[Yellow]}], &#xD;
      animalize[shapes[[6]],{False,0.7,Darker[Blue]}],&#xD;
      animalize[shapes[[14]],{False,0.,Darker[Brown]}],&#xD;
      animalize[shapes[[4]],{False,0.5,Darker[Red]}],&#xD;
      animalize[shapes[[23]],{False,0,Darker[Orange]}],&#xD;
      animalize[shapes[[76]],{False,0,Darker[Orange,0.6]}],&#xD;
      animalize[shapes[[95]],{False,-1.5,Darker[Green,0.4]}], &#xD;
      animalize[shapes[[9]],{False,0.,Brown}],&#xD;
      animalize[shapes[[163]],{False,1.1,Darker[Purple]}]},&#xD;
    Spacings-&amp;gt;{5,-20}]&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
Looking at the last selection shows the importance of one or two eyes in the shapes ([Yang2015][12]). Eyes are often used by nature for deception ([Steven2014][13]).&#xD;
&#xD;
A small Manipulate will allow to optimize the animal-perception by changing color, orientation, and aspect ratio.&#xD;
&#xD;
    makeManipulate[shape_]:=Manipulate[Graphics[ recolor[rotate[If[f, flip,Identity]@ #[[1]],?],col],&#xD;
    ImageSize -&amp;gt; 120,AspectRatio-&amp;gt;ar,PlotRange -&amp;gt; All],&#xD;
    OpenerView[{&amp;#034;modify&amp;#034;,Column[{&#xD;
    Control[{{?,0,&amp;#034;rotate&amp;#034;},-Pi,Pi,ImageSize-&amp;gt;Small}],&#xD;
    Control[{{f,False,&amp;#034;reflect&amp;#034;},{True,False},ImageSize-&amp;gt;Small}],&#xD;
    Control[{{col, Darker[Blue],&amp;#034;color&amp;#034;},Red,ImageSize-&amp;gt;Tiny}],&#xD;
    Control[{{ar, Automatic,&amp;#034;aspect ratio&amp;#034;},0.2,5,ImageSize-&amp;gt;Small}]}]}],&#xD;
    SaveDefinitions-&amp;gt;True,TrackedSymbols:&amp;gt;True]&amp;amp;[smooth[#]]&amp;amp;@ shape&#xD;
    &#xD;
    Manipulate[makeManipulate[shapes[[j]]],{{j,141,&amp;#034;&amp;#034;},1, Length[shapes],1,Appearance-&amp;gt;&amp;#034;Labeled&amp;#034;}]&#xD;
&#xD;
![enter image description here][14]&#xD;
&#xD;
Here are some more animal-shapes found in other random images. &#xD;
&#xD;
![enter image description here][15]&#xD;
&#xD;
One could now try to automate the finding of animals using ImageIdentify. In general, the interpretation of ImageIdentify will depend on the image orientation. So, we maximize over different orientations.&#xD;
&#xD;
    getOptimalAnimal[shape_] := &#xD;
    Module[{s=smooth[shape][[1]],tab,ras,tab2},&#xD;
    tab=Table[{(ras=Rasterize[Graphics[rotate[s,\[Alpha]],ImageSize -&amp;gt; 120,PlotRange -&amp;gt; All]]),&#xD;
          Normal@KeyDrop[ImageIdentify[ras,&amp;#034;animal&amp;#034;,2,&amp;#034;Probability&amp;#034;],Entity[&amp;#034;Concept&amp;#034;,#]&amp;amp;/@&#xD;
     {&amp;#034;Person::93r37&amp;#034;,&amp;#034;Hominid::tt93h&amp;#034;,&amp;#034;Mammal::nt5bz&amp;#034;,&#xD;
    &amp;#034;SeaStar::46w97&amp;#034;,&amp;#034;Shark::632s8&amp;#034;,&amp;#034;CanisFamiliaris::597qc&amp;#034;}]},&#xD;
    {\[Alpha], 0, 2Pi, 2Pi/24}]; &#xD;
    tab2=Sort[{#2[[1,2]], #2[[1,1]], #1}&amp;amp;@@@DeleteCases[ tab,{_,{}}]];&#xD;
    {tab2[[-1,3]]-&amp;gt;tab2[[-1,2]],&amp;#034;Probabilty&amp;#034; -&amp;gt; tab2[[-1,1]]}]&#xD;
&#xD;
As ImageIdentify was trained on real photographs, it is not the ideal tool for this task. It is biased towards humans, mammals, and sharks.&#xD;
&#xD;
    getOptimalAnimal[shapes[[10]]]&#xD;
&#xD;
![enter image description here][16]&#xD;
&#xD;
    getOptimalAnimal[shapes[[27]]]&#xD;
&#xD;
![enter image description here][17]&#xD;
&#xD;
To answer the original question: in a random 400x400 pixel image, one easily finds a few dozen animals. Here are four dozen animal-shape like smoothed regions from random 400x400 image.&#xD;
&#xD;
    Module[{gs, gs2},&#xD;
     SeedRandom[2222];&#xD;
     gs = getShapes[{2, 1}, 400];&#xD;
     gs2 = {animalize[gs[[3]], {False, 0, GrayLevel[0.1]}], &#xD;
       animalize[gs[[6]], {False, 1, GrayLevel[0.1]}], &#xD;
       animalize[gs[[9]], {False, 1.3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[15]], {False, -1, GrayLevel[0.1]}], &#xD;
       animalize[gs[[17]], {False, 0.3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[30]], {True, 2.3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[39]], {False, 0.3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[40]], {True, -0.1, GrayLevel[0.1]}], &#xD;
       animalize[gs[[48]], {False, -0.1, GrayLevel[0.1]}], &#xD;
       animalize[gs[[53]], {True, -0.1, GrayLevel[0.1]}], &#xD;
       animalize[gs[[55]], {True, -0.1, GrayLevel[0.1]}], &#xD;
       animalize[gs[[62]], {True, 2.3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[64]], {False, 0, GrayLevel[0.1]}], &#xD;
       animalize[gs[[65]], {False, 0, GrayLevel[0.1]}], &#xD;
       animalize[gs[[68]], {False, -0.2, GrayLevel[0.1]}], &#xD;
       animalize[gs[[73]], {True, -0.3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[81]], {False, 0.2, GrayLevel[0.1]}], &#xD;
       animalize[gs[[86]], {True, 3.4, GrayLevel[0.1]}], &#xD;
       animalize[gs[[97]], {False, 0.3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[100]], {False, 0.9, GrayLevel[0.1]}], &#xD;
       animalize[gs[[101]], {False, 2.6, GrayLevel[0.1]}], &#xD;
       animalize[gs[[115]], {False, 4.3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[124]], {False, 0, GrayLevel[0.1]}], &#xD;
       animalize[gs[[125]], {False, 2.9, GrayLevel[0.1]}], &#xD;
       animalize[gs[[139]], {False, 0, GrayLevel[0.1]}], &#xD;
       animalize[gs[[146]], {False, -1.6, GrayLevel[0.1]}], &#xD;
       animalize[gs[[175]], {False, -1., GrayLevel[0.1]}], &#xD;
       animalize[gs[[201]], {True, -0.5, GrayLevel[0.1]}], &#xD;
       animalize[gs[[209]], {True, 3.1, GrayLevel[0.1]}], &#xD;
       animalize[gs[[210]], {False, -1.4, GrayLevel[0.1]}], &#xD;
       animalize[gs[[218]], {True, 3.2, GrayLevel[0.1]}], &#xD;
       animalize[gs[[227]], {True, -0.3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[229]], {True, 0.9, GrayLevel[0.1]}], &#xD;
       animalize[gs[[253]], {True, 0., GrayLevel[0.1]}], &#xD;
       animalize[gs[[273]], {True, -0.3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[278]], {True, 1., GrayLevel[0.1]}], &#xD;
       animalize[gs[[282]], {True, 3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[298]], {False, 0, GrayLevel[0.1]}], &#xD;
       animalize[gs[[299]], {False, 0.6, GrayLevel[0.1]}], &#xD;
       animalize[gs[[318]], {False, 2., GrayLevel[0.1]}], &#xD;
       animalize[gs[[326]], {False, 3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[340]], {False, -1.3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[352]], {True, -13, GrayLevel[0.1]}], &#xD;
       animalize[gs[[361]], {True, -13, GrayLevel[0.1]}], &#xD;
       animalize[gs[[365]], {False, 2.4, GrayLevel[0.1]}], &#xD;
       animalize[gs[[377]], {True, 2.6, GrayLevel[0.1]}], &#xD;
       animalize[gs[[395]], {False, 0.3, GrayLevel[0.1]}], &#xD;
       animalize[gs[[405]], {True, 0.3, GrayLevel[0.1]}]};&#xD;
     Grid[Partition[Framed[Show[#, ImageSize -&amp;gt; 100]] &amp;amp; /@ &#xD;
        SortBy[gs2, FullOptions[#, AspectRatio] &amp;amp;], 6]]]&#xD;
&#xD;
![enter image description here][18]&#xD;
&#xD;
Using different method options for ImageMesh gives different results. Here are some animal-shaped regions from a 300*300 image and method &amp;#034;MarchingSquares&amp;#034;.&#xD;
&#xD;
![enter image description here][19]&#xD;
&#xD;
&#xD;
  [1]: https://en.wikipedia.org/wiki/Pareidolia&#xD;
  [2]: https://dx.doi.org/10.1016/j.cortex.2014.01.013&#xD;
  [3]: https://doi.org/10.1163/15736121-12341320&#xD;
  [4]: http://dx.doi.org/10.1093/cercor/bhr315&#xD;
  [5]: https://www.scientificamerican.com/article/a-faithful-resemblance/&#xD;
  [6]: http://dx.doi.org/10.1167/12.1.25&#xD;
  [7]: http://dx.doi.org/10.1073/pnas.1312648110&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=4356yretet465yhdfreg5w4ytrg.png&amp;amp;userId=11733&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=fdfgnsgt65whtr.png&amp;amp;userId=11733&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=dfgdhcvbcbcx34tq.png&amp;amp;userId=11733&#xD;
  [11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=dfg4dsgdfsgdqy546hfgsnbv.png&amp;amp;userId=11733&#xD;
  [12]: http://arxiv.org/pdf/1509.04954&#xD;
  [13]: http://dx.doi.org/10.1093/czoolo/60.1.26&#xD;
  [14]: http://community.wolfram.com//c/portal/getImageAttachment?filename=weretregdfdgdscbx3454y6rtdfgsb.png&amp;amp;userId=11733&#xD;
  [15]: http://community.wolfram.com//c/portal/getImageAttachment?filename=sadfert543wyhdfgdhfd5676e565w44.png&amp;amp;userId=11733&#xD;
  [16]: http://community.wolfram.com//c/portal/getImageAttachment?filename=67567etfhg54yw.png&amp;amp;userId=11733&#xD;
  [17]: http://community.wolfram.com//c/portal/getImageAttachment?filename=sadf345q4yrthgd.png&amp;amp;userId=11733&#xD;
  [18]: http://community.wolfram.com//c/portal/getImageAttachment?filename=kfkeighsmf534yrthgfds.png&amp;amp;userId=11733&#xD;
  [19]: http://community.wolfram.com//c/portal/getImageAttachment?filename=fdsg65udfsdstrdgjyt7u56uw56rh.png&amp;amp;userId=11733</description>
    <dc:creator>Michael Trott</dc:creator>
    <dc:date>2017-01-15T10:54:26Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/404292">
    <title>JaroWinkler distance in Wolfram Language ?</title>
    <link>https://community.wolfram.com/groups/-/m/t/404292</link>
    <description>Does anyone have an idea for an efficient implementation of [JaroWinkler distance][1]? If there is a built in function with a different name it would be great, please let me know. If not, perhaps a modification of [Levenshtein][2] or similar would do or a compiled version (not sure which functions to use to make it compilable). I know good etiquette is to show some code, but I have to compare millions of strings pairwise and need the most efficient approach. Any advice would be appreciated - thanks in advance! &#xD;
&#xD;
BTW does anyone see any link between Shannon Entropy and Levenshtein and similar distances? Is it possible to talk about distance metric between strings in terms of information change needed to turn one string into the other? &#xD;
&#xD;
  [1]: https://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance&#xD;
  [2]: http://reference.wolfram.com/language/ref/EditDistance.html</description>
    <dc:creator>Sam Carrettie</dc:creator>
    <dc:date>2014-12-09T02:00:25Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/114911">
    <title>Unlawful primes</title>
    <link>https://community.wolfram.com/groups/-/m/t/114911</link>
    <description>How small can a description of a large prime number be? There are the Fermat primes 2^n-1 for certain n, and in base 2 these are a sequence of ones.  In base 10, if you have just zeros and two ones, then the only primes of that form are 11 and 101.  If there are three ones then it is divisible by three.  But what about four ones?  It seems wrong to me that there might be an unbounded number of such primes.&#xD;
&#xD;
That&amp;#039;s what some brief experiments suggest though.&#xD;
[mcode]1+10^4+10^18+10^201 == 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000010001[/mcode]is the largest one I found.  Also I don&amp;#039;t notice any patterns, e.g. here in the first 200 such primes&#xD;
&#xD;
[img=width: 68px; height: 432px;]/c/portal/getImageAttachment?filename=primes-1111.jpg&amp;amp;userId=23275[/img]&#xD;
&#xD;
and here are the first 254 primes with nonzero digits {1,2,1}&#xD;
&#xD;
[img=width: 347px; height: 432px;]/c/portal/getImageAttachment?filename=primes-121.jpg&amp;amp;userId=23275[/img]&#xD;
&#xD;
the largest found is&#xD;
[mcode]1+2*10^14+10^201 == 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000001[/mcode]Does anyone else have any primes which don&amp;#039;t seem like they should be prime?  The more extreme the better.</description>
    <dc:creator>Todd Rowland</dc:creator>
    <dc:date>2013-09-03T04:50:53Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/235291">
    <title>Random Snowflake Generator Based on Cellular Automaton</title>
    <link>https://community.wolfram.com/groups/-/m/t/235291</link>
    <description>[img]/c/portal/getImageAttachment?filename=fig0.gif&amp;amp;userId=93201[/img]&#xD;
&#xD;
Some time ago one of my friends asked me whether it is possible to design a cellular automaton which can generate realistic snowflakes. I recall my crystallography and thermodynamics knowledge and came up a very simple yet impressive model.&#xD;
&#xD;
&#xD;
[size=5][b]The Regular Triangular Lattice[/b][/size]&#xD;
&#xD;
First of all, we are trying to simulate snowflake, which is a kind of hexagonal crystal. So it should be best to construct our CA on a regular hexagonal grid, i.e. regular triangular lattice.&#xD;
&#xD;
We all know [b]CellularAutomaton[/b] inherently works on rectangle lattices (&amp;#034;4-lattice&amp;#034; for short), so how can we deduce a triangular lattice (&amp;#034;3-lattice&amp;#034; for short) on it? Well, the differences between rect-lattice and triangular one is just a geometric transformation.&#xD;
&#xD;
To demonstrate that, have a look at the following 4-lattice, with a blue square highlighting the range-1 [url=http://mathworld.wolfram.com/MooreNeighborhood.html]Moore neighborhood[/url]:&#xD;
&#xD;
[img=width: 388px; height: 396px;]/c/portal/getImageAttachment?filename=fig1.gif&amp;amp;userId=93201[/img]&#xD;
&#xD;
Clearly there is always a hexagon (the green area) in this kind of neighborhood.&#xD;
&#xD;
So forming a regular 3-lattice is as straightforward as doing a simple affine transformation (basically a shearing and a scaling):&#xD;
&#xD;
[img=width: 484px; height: 304px;]/c/portal/getImageAttachment?filename=fig2.gif&amp;amp;userId=93201[/img]&#xD;
&#xD;
So to take advantage of all the power of [b]CellularAutomaton[/b], all we have to do, is to use a following special 6-neighborhood stencil on rectangle lattices, meanwhile our model can be discussed and constructed on regular triangular lattice convieniently:&#xD;
&#xD;
[img=width: 118px; height: 57px;]/c/portal/getImageAttachment?filename=fig3.png&amp;amp;userId=93201[/img]&#xD;
&#xD;
And after the calculation, we can perform the affine transformation with following functions to get a nice hexagonal grid picture.&#xD;
&#xD;
[mcode]Clear[vertexFunc]&#xD;
&#xD;
vertexFunc = &#xD;
        Compile[{{para, _Real, 1}}, &#xD;
            Module[{center, ratio}, center = para[[1 ;; 2]];&#xD;
                ratio = para[[3]];&#xD;
                {Re[#], Im[#]} + {{1, -(1/2)}, {0, &#xD;
                                        Sqrt[3]/2}}.Reverse[{-1, 1} center + {3, 0}] &amp;amp; /@ (ratio 1/&#xD;
                                Sqrt[3] E^(I ?/6) E^(I Range[6] ?/3))], &#xD;
            RuntimeAttributes -&amp;gt; {Listable}, Parallelization -&amp;gt; True, &#xD;
            RuntimeOptions -&amp;gt; &amp;#034;Speed&amp;#034;&#xD;
            (*,CompilationTarget?&amp;#034;C&amp;#034;*)];&#xD;
&#xD;
Clear[displayfunc]&#xD;
displayfunc[array_, ratio_] := &#xD;
    Graphics[{FaceForm[{ColorData[&amp;#034;DeepSeaColors&amp;#034;][3]}], &#xD;
            EdgeForm[{ColorData[&amp;#034;DeepSeaColors&amp;#034;][4]}], &#xD;
            Polygon[vertexFunc[Append[#, ratio]] &amp;amp; /@ Position[array, 1]]}, &#xD;
        Background -&amp;gt; ColorData[&amp;#034;DeepSeaColors&amp;#034;][0]][/mcode]&#xD;
&#xD;
&#xD;
[size=5][b]The Model[/b][/size]&#xD;
&#xD;
To construct the crystallization model, let&amp;#039;s consider one of the 6-neighborhood stencil, where each cell represents a minimal crystal unit:&#xD;
&#xD;
[img=width: 261px; height: 236px;]/c/portal/getImageAttachment?filename=fig4.png&amp;amp;userId=93201[/img]&#xD;
&#xD;
A simple model will need only 2 states: [b]0[/b] for &amp;#034;[i]It&amp;#039;s empty[/i]&amp;#034;, [b]1[/b] for &amp;#034;[i]There is a crystal unit[/i]&amp;#034;. So by considering all (except the [b]000000[/b] one, because we are generating ONE snowflake thus don&amp;#039;t want a crystall randomly arises from void) [b]6-bit[/b] non-negative numbers, we can have a finite set of possible arrangements of the neighborhood:&#xD;
&#xD;
[mcode]stateSet = Tuples[{0, 1}, 6] // Rest[/mcode]&#xD;
However, from the viewpoint of physics, any two arrangements which can be transformed into each other with only rotation and reflection should be considered as the same arrangement in the sense of their physical effects on the central cell (i.e. cell[size=1]2,2[/size]) are the same:&#xD;
&#xD;
[img=width: 363px; height: 117px;]/c/portal/getImageAttachment?filename=fig5.png&amp;amp;userId=93201[/img]&#xD;
&#xD;
So we should gather [b]stateSet[/b] with above equivalence class:&#xD;
&#xD;
[mcode]gatherTestFunc = Function[lst, Union[Join[&#xD;
&#xD;
                    RotateLeft[lst, # - 1] &amp;amp; /@ Flatten[Position[lst, 1]],&#xD;
                    RotateLeft[Reverse[lst], # - 1] &amp;amp; /@ &#xD;
                        Flatten[Position[Reverse[lst], 1]]&#xD;
                    ]]];&#xD;
&#xD;
stateClsSet = Sort /@ Gather[stateSet, gatherTestFunc[#1] == gatherTestFunc[#2] &amp;amp;];&#xD;
&#xD;
stateClsSetHomogeneous = ArrayPad[#, {{0, 12 - Length@#}, {0, 0}}] &amp;amp; /@ stateClsSet;[/mcode]&#xD;
Which turned out to be [b]12[/b] classes in total:&#xD;
&#xD;
[img=width: 710px; height: 127px;]/c/portal/getImageAttachment?filename=fig6.png&amp;amp;userId=93201[/img]&#xD;
&#xD;
Now from the viewpoint of cellular automaton, we need to establish a set of rules on how should any 6-neighborhood arrangement, i.e. those 12 kinds of equivalence classes, determine the state of the central cell.&#xD;
&#xD;
There are 4 kinds of possible transformations on cell[size=1]2,2[/size]: [b]0 --&amp;gt; 1[/b] is called [b]frozen[/b], [b]0 --&amp;gt; 0[/b] is [b]remaining empty[/b], [b]1 --&amp;gt; 1[/b] is [b]remaining frozen[/b], and [b]1 --&amp;gt; 0[/b] is called [b]melten[/b]. To make things more interesting and to explore more possibilities, we can introduce probability here, so certain arrangement will give certain probabilities corresponding to the 4 kinds of transformations. But notice that because of the unitarity of probability, we have Prob(frozen) + Prob(0-&amp;gt;0) = 1 and Prob(melten) + Prob(1-&amp;gt;1) = 1, so only 2 of the 4 probabilities are independent. In the following, we&amp;#039;ll choose Prob(frozen) and Prob(melten), and denote them as [b]pFrozen[/b] and [b]pMelten[/b].&#xD;
&#xD;
[img=width: 800px; height: 367px;]/c/portal/getImageAttachment?filename=fig7.png&amp;amp;userId=93201[/img]&#xD;
&#xD;
Back to physics / thermodynamics, those 24 probabilities, [b]pFrozen[/b] and [b]pMelten[/b], can of corse be determined by serious physical models, or they can be chosen randomly just for fun. For example, an intuitive (and naive) idea would be to believe an empty cell nearby a sharp pointed end or with abundant moisture source will have a high [b]pFrozen[/b]. (People who are interested in the serious physical models should not miss [url=http://psoup.math.wisc.edu/Snowfakes.htm]the Gravner-Griffeath Snowfakes model[/url].)&#xD;
&#xD;
Now we have the grid, the stencil, the neighborhood arrangement set and the transfer probabilities, we&amp;#039;re offically ready to construct our cellular automaton rules.&#xD;
Following the above discussion, the construction is straightforward. There are only two points which need to pay attention to. One is to keep in mind that the rule function is applied on the 3x3 stencil, so even cell[size=1]1,1[/size] and cell[size=1]3,3[/size] has nothing to do with our model, don&amp;#039;t forget handling them. The second is to use a [b]SeedRandom[/b] function to make sure same arrangement gives same result in same time step, otherwise the 6-fold rotational symmetry and 3 axes of reflection symmetry will both break!&#xD;
&#xD;
[mcode]Clear[ruleFunc]&#xD;
&#xD;
ruleFunc = With[{&#xD;
                stateClsSetHomogeneous = stateClsSetHomogeneous,&#xD;
                seedStore = RandomInteger[{0, 1000}, 1000],&#xD;
                pFreeze = {1,   0,     0.6,   0,     0.3,   0.15,   0,     0.2,   0,     0.2,   0,     0.8},&#xD;
                pMelt   = {0,   0.7,   0.5,   0.7,   0.7,   0.5,    0.3,   0.5,   0.3,   0.2,   0.1,   0  }&#xD;
                },&#xD;
            Compile[{{neighborarry, _Integer, 2}, {step, _Integer}},&#xD;
                Module[{cv, neighborlst, cls, rand},&#xD;
                    cv = neighborarry[[2, 2]];&#xD;
                    neighborlst = {#[[1, 2]], #[[1, 3]], #[[2, 3]], #[[3, 2]], #[[3, &#xD;
                                        1]], #[[2, 1]]} &amp;amp;[neighborarry];&#xD;
                    If[Total[neighborlst] == 0, cv,&#xD;
                        cls = Position[stateClsSetHomogeneous, neighborlst][[1, 1]];&#xD;
                        SeedRandom[seedStore[[step + 1]]];&#xD;
                        rand = RandomReal[];&#xD;
                        Boole@If[cv == 0, rand &amp;lt; pFreeze[[cls]], rand &amp;gt; pMelt[[cls]]]&#xD;
                        ]],&#xD;
                (*CompilationTarget -&amp;gt; &amp;#034;C&amp;#034;,*)&#xD;
                RuntimeAttributes -&amp;gt; {Listable}, Parallelization -&amp;gt; True, &#xD;
                RuntimeOptions -&amp;gt; &amp;#034;Speed&amp;#034;&#xD;
                ]&#xD;
            ];[/mcode]&#xD;
(Note: re-compile the rule function [b]ruleFunc[/b] will give a different set of [b]seedStore[/b] thus a different growth path.)&#xD;
&#xD;
Now everything is ready, let&amp;#039;s grow a snowflake from the beginning! :D&#xD;
&#xD;
[mcode]dataSet = Module[{&#xD;
&#xD;
                    rule,&#xD;
                    initM = {{&#xD;
                                    {0, 0, 0},&#xD;
                                    {0, 1, 0},&#xD;
                                    {0, 0, 0}&#xD;
                                }, 0},&#xD;
                    rspec = {1, 1},&#xD;
                    tmin = 0, tmax = 100, dt = 1},&#xD;
                rule = {ruleFunc, {}, rspec};&#xD;
                CellularAutomaton[rule, initM, {{tmin, tmax, dt}}]&#xD;
                ]; // AbsoluteTiming&#xD;
&#xD;
Animate[&#xD;
    Rotate[displayfunc[dataSet[[k]], .8], 90 °],&#xD;
    {k, 1, Length[dataSet], 1},&#xD;
    AnimationDirection -&amp;gt; ForwardBackward,&#xD;
    AnimationRunning -&amp;gt; False, DisplayAllSteps -&amp;gt; True&#xD;
    ][/mcode]&#xD;
&#xD;
[img]/c/portal/getImageAttachment?filename=fig0.gif&amp;amp;userId=93201[/img]&#xD;
&#xD;
&#xD;
&#xD;
[size=5][b]Possible Improvements[/b][/size]&#xD;
&#xD;
We used a [b]SeedRandom[/b] function in our CA rule function to force the 6-fold rotational symmetry and 3 axes of reflection symmetry, and performed the CA calculation on all cells. However, this so called [url=http://demonstrations.wolfram.com/DihedralGroupNOfOrder2n/][i]D[/i][size=1]6[/size] symmetry[/url] can (and should) be integrated into our model, which will saving [b]11/12[/b] of the calculation. Also, the randomness of the growth path comes from [b]seedStore[/b], so to generate a new growth path, we have to re-compile the rule function. But with a improved model as described above, this constraint will no longer exist.&#xD;
&#xD;
[img=width: 800px; height: 177px;]/c/portal/getImageAttachment?filename=fig8.png&amp;amp;userId=93201[/img]&#xD;
[b][size=4]&#xD;
&#xD;
[size=5]Open question [/size]&#xD;
[/size][/b]&#xD;
Can we construct a well-organized structure (like the crystals) from a cellular automaton defined on an [b]irregular[/b] grid? While I believe the answer is [i]yes[/i], the next question would be [i]how?[/i]</description>
    <dc:creator>Silvia Hao</dc:creator>
    <dc:date>2014-04-11T16:03:33Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/526743">
    <title>[JAM] CellularAutomaton Code Jam Wolfram Summer School 2015</title>
    <link>https://community.wolfram.com/groups/-/m/t/526743</link>
    <description>[Wolfram Science Summer School][1] and [Wolfram Innovation Summer School][2] are happening now in Boston at Bentley University. The goal of this Code Jam is to post interesting code snippets that fit the Wolfram Language functionality described in detail below. By &amp;#034;interesting&amp;#034; I mean simple programs that generate complex patterns. We will be jamming with our students, but everyone is welcome to join. Let&amp;#039;s have some fun!&#xD;
&#xD;
In this Code Jam we will take a look at the CellularAutomaton (CA) function and its syntax **for rules defined as functions**. This may sound a bit confusing, so let&amp;#039;s take a look at some examples. First, if you haven&amp;#039;t yet, you have to make yourself familiar with the [CellularAutomaton][3] function. The most well known cases are integer Wolfram indexes for [CA rules][4], for instance for the celebrated rule 30:&#xD;
&#xD;
    ArrayPlot[CellularAutomaton[30, RandomInteger[1, 100], 50]]&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
But CellularAutomaton can take a function as a rule. Below are some examples. Use an arbitrary symbolic function f as the rule to apply to range-1 neighbors:&#xD;
&#xD;
    CellularAutomaton[{f[#] &amp;amp;, {}, 1}, {a, b, c}, 1]&#xD;
&#xD;
`{{a, b, c}, {f[{c, a, b}], f[{a, b, c}], f[{b, c, a}]}}`&#xD;
&#xD;
Set up a &amp;#034;Pascal&amp;#039;s triangle cellular automaton&amp;#034;:&#xD;
&#xD;
    CellularAutomaton[{f[#] &amp;amp;, {}, 1/2}, {a, b, c}, 1]&#xD;
&#xD;
`{{a, b, c}, {f[{c, a}], f[{a, b}], f[{b, c}]}}`&#xD;
&#xD;
    CellularAutomaton[{Total[#] &amp;amp;, {}, 1/2}, {{1}, 0}, 3] &#xD;
&#xD;
`{{1, 0, 0, 0}, {1, 1, 0, 0}, {1, 2, 1, 0}, {1, 3, 3, 1}}`&#xD;
&#xD;
Additive cellular automaton modulo 4:&#xD;
&#xD;
    ArrayPlot[&#xD;
     CellularAutomaton[{Mod[Total[#], 4] &amp;amp;, {}, 1}, {{1}, 0}, 50], &#xD;
     ColorFunction -&amp;gt; &amp;#034;Rainbow&amp;#034;]&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
The second argument to the function is the step number:&#xD;
&#xD;
    CellularAutomaton[{f[#1, #2] &amp;amp;, {}, 1}, {a, b, c}, 1]&#xD;
&#xD;
`{{a, b, c}, {f[{c, a, b}, 1], f[{a, b, c}, 1], f[{b, c, a}, 1]}}`&#xD;
&#xD;
    CellularAutomaton[{f, {}, 1}, {a, b, c}, 1]&#xD;
&#xD;
`{{a, b, c}, {f[{c, a, b}, 1], f[{a, b, c}, 1], f[{b, c, a}, 1]}}`&#xD;
&#xD;
Change the rule at successive steps; #2 gives the step number:&#xD;
&#xD;
    ArrayPlot[&#xD;
     CellularAutomaton[{Mod[Total[#] + #2, 4] &amp;amp;, {}, 1}, {{1}, 0}, 30], &#xD;
     ColorFunction -&amp;gt; &amp;#034;Rainbow&amp;#034;]&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
Use continuous values for cells:&#xD;
&#xD;
    ArrayPlot[CellularAutomaton[{Mod[Total[#]/2, 1] &amp;amp;, {}, 1}, {{1}, 0}, 50]]&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
    Manipulate[&#xD;
     ArrayPlot[&#xD;
      CellularAutomaton[{Mod[s Total[#], 1] &amp;amp;, {}, 2}, {{1}, 0}, 50],&#xD;
      ColorFunction -&amp;gt; &amp;#034;Rainbow&amp;#034;, PixelConstrained -&amp;gt; 3]&#xD;
     , {s, .01, .99}]&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
Try different functions and different initial conditions.  They can be strings, numbers, graphics or expressions.  Try ArrayPlot but also try other visualization tools like Grid. Try them out.  Post code, images, and text comments. You can also comment on other people&amp;#039;s code.&#xD;
&#xD;
  [1]: https://www.wolframscience.com/summerschool/&#xD;
  [2]: http://education.wolfram.com/summer/innovation/&#xD;
  [3]: http://reference.wolfram.com/language/ref/CellularAutomaton.html&#xD;
  [4]: http://www.wolframscience.com/nksonline/page-53&#xD;
  [5]: /c/portal/getImageAttachment?filename=SSCJSS2015_1.png&amp;amp;userId=11733&#xD;
  [6]: /c/portal/getImageAttachment?filename=SSCJSS2015_2.png&amp;amp;userId=11733&#xD;
  [7]: /c/portal/getImageAttachment?filename=SSCJSS2015_3.png&amp;amp;userId=11733&#xD;
  [8]: /c/portal/getImageAttachment?filename=SSCJSS2015_4.png&amp;amp;userId=11733&#xD;
  [9]: /c/portal/getImageAttachment?filename=SSCJSS2015_5.png&amp;amp;userId=11733&#xD;
  [10]: /c/portal/getImageAttachment?filename=4926wsdaf345678iruyjtdhfgsdasrt4.gif&amp;amp;userId=11733</description>
    <dc:creator>Vitaliy Kaurov</dc:creator>
    <dc:date>2015-07-09T08:46:23Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/121507">
    <title>Optimal lighting configuration of 5 lamps in a square room</title>
    <link>https://community.wolfram.com/groups/-/m/t/121507</link>
    <description>[b]With 5 point-source lights in a square room, what is the optimal configuration for even lighting?[/b]&#xD;
&#xD;
To make this question concrete, say that each wall has length 1, the room has no height (i.e., two dimensional) and we have five identical lights that are pointsized and want to know the optimal placement that maximizes even lighting.  That could mean&#xD;
[mcode]f = 1/((x - x1)^2 + (y - y1)^2) + 1/((x - x2)^2 + (y - y2)^2) + 1/((x - x3)^2 + (y - y3)^2) + 1/((x - x4)^2 + (y - y4)^2) + 1/((x - x5)^2 + (y - y5)^2);[/mcode]&#xD;
a) maximizing the value of the minimal illumination [mcode]Minimize[f, {x,0,1},{y,0,1}][/mcode]or an integral measure like&#xD;
&#xD;
b) maximizing the total illumination where the brightest areas are considered as being some default value, e.g., the value of [mcode]Integrate[Min[f, f0], {x,0,1},{y,0,1}][/mcode]&#xD;
For an example configuration of light sources with&#xD;
[mcode]f = With[{n = 5}, Sum[1/((x - (.5 + .45 Cos[2 Pi i/n]))^2 + (y - (.5 + .45 Sin[2 Pi i/n]))^2), {i, 0, n - 1}]]&#xD;
[/mcode]and then here is the minimum illumination&#xD;
[mcode]NMinimize[{f, 0 &amp;lt;= x &amp;lt;= 1 &amp;amp;&amp;amp; 0 &amp;lt;= y &amp;lt;= 1}, {x, y}] (*{14.349, {x -&amp;gt; 1., y -&amp;gt; 1.}}*)&#xD;
[/mcode]and here that point is shown on a contour plot&#xD;
&#xD;
[img=width: 360px; height: 359px;]/c/portal/getImageAttachment?filename=lights5.jpg&amp;amp;userId=23275[/img]&#xD;
&#xD;
For that configuration here is the integral (which I had to approximate with a Sum)&#xD;
[mcode]Sum[Min[1.2 (14.349), f], {x, 0.0001, 1, .01}, {y, 0.0001, 1, .01}]/10^4 (*17.2146*)&#xD;
[/mcode]I&amp;#039;d be interested in optimization approaches, but also aesthetic approaches, e.g., symmetries, angles, shadows, or patterns made by contour lines.&#xD;
&#xD;
To generalize, not only other numbers of lights, but try tacking on albedo of 50% so the wall reflect half of the light they receive.</description>
    <dc:creator>Todd Rowland</dc:creator>
    <dc:date>2013-09-10T16:45:23Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/108323">
    <title>Doodling in Mathematica: DRAGON TREES</title>
    <link>https://community.wolfram.com/groups/-/m/t/108323</link>
    <description>Last week [url=http://www.youtube.com/user/Vihart/videos]Vi Hart[/url] submitted a new class titled [url=http://youtu.be/EdyociU35u8]Doodling in Math Class: DRAGONS[/url]. There, she introduced a family of fractals known as [url=http://en.wikipedia.org/wiki/Dragon_curve]dragon curves[/url], see here below the most famous one, the Heighway dragon:[quote]The Heighway dragon (also known as the HarterHeighway dragon or the Jurassic Park dragon) was first investigated by NASA physicists John Heighway, Bruce Banks, and William Harter. It was described by Martin Gardner in his Scientific American column Mathematical Games in 1967. Many of its properties were first published by Chandler Davis and Donald Knuth. It appeared on the section title pages of the Michael Crichton novel Jurassic Park.
 ? Wikipedia[/quote][url=http://youtu.be/EdyociU35u8][img=width: 600px; height: 380px;]/c/portal/getImageAttachment?filename=vihartDragon.png&amp;amp;userId=56204[/img][/url]

Wouldnt it be great to doodle fractals as fast as she does? What about doodling dragons in Mathematica?

[img=width: 600px; height: 502px;]/c/portal/getImageAttachment?filename=DownBinary.gif&amp;amp;userId=56204[/img]

Two years ago, when I was playing with the mind-blowing [url=http://demonstrations.wolfram.com/TreeBender/]Tree Bender[/url] demonstration by [url=http://blog.wolfram.com/author/theodore-gray/]Theodore Gray[/url], I spotted a striking property. When the two branch-locators were placed in a symmetrical arrangement along the pair of horizontal line-segments {{-0.5,0.5},{0.5,0.5}} and {{-0.5,-0.5},{0.5,-0.5}}, the resulting trees were always forming dragons! 

[img=width: 800px; height: 255px;]/c/portal/getImageAttachment?filename=DragonTrees.jpg&amp;amp;userId=56204[/img]

I was so excited by this observation that I ended up carrying out a whole [url=http://pille.iwr.uni-heidelberg.de/~fractaltree01/]project[/url] about fractal trees, I published two papers presenting the n-ary symmetric trees with tip-to-tip self-contact, I 3D-printed some [url=http://shpws.me/ouuH]SuperFractals[/url] generated by these trees, and I generalized this special class of fractals to three dimensional fractal trees during my participation at the 2013 [url=http://www.wolframscience.com/summerschool/]Wolfram Science Summer School[/url]. For now lets focus on doodling dragons, I will talk about these related projects in future discussions.

There are four different ways to place symmetrically the pair of locators along the pair of horizontal lines:
[list=1]
[*]One with the first pair of branches constrained to move along the upper line in a mirror symmetric way: Lévy Trees.
[*]One with the first pair of branches constrained to move along the lower line in a mirror symmetric way: Koch Trees.
[*]One with the first pair of branches constrained to move along both horizontal lines in an opposite way to each other, 180º: Polynomial Trees.
[*]And one with the first pair of branches constrained to move along both horizontal lines in a mirror symmetric way: Jurassic Park Trees.
[/list][img=width: 800px; height: 500px;]/c/portal/getImageAttachment?filename=Levy_Tres.gif&amp;amp;userId=56204[/img]

[img=width: 800px; height: 500px;]/c/portal/getImageAttachment?filename=Koch_Trees.gif&amp;amp;userId=56204[/img]

[img=width: 800px; height: 400px;]/c/portal/getImageAttachment?filename=Polynomial_Trees.gif&amp;amp;userId=56204[/img]

[img=width: 800px; height: 500px;]/c/portal/getImageAttachment?filename=Jurassic_Trees.gif&amp;amp;userId=56204[/img]

Here below you have my pieces of code for doodling the four different kinds of binary dragon trees. Notice that Ive also added the final leaves in red and some meaningful labels to explore these trees with high precision (press Alt-key while moving the branch locator to slowly change the parameters).


[size=3][b]Lévy Trees Doodler
[/b][/size]
[img=width: 800px; height: 549px;]/c/portal/getImageAttachment?filename=levy.png&amp;amp;userId=56204[/img]
[mcode]Manipulate[
Module[{branches=NestList[Flatten[Map[{{#[[2]],#[[2]]+{Reverse[{pt1[[1]],0.5}],{-1,1}*{pt1[[1]],0.5}}.(#[[2]]-#[[1]])},{#[[2]],#[[2]]+{Reverse[{-pt1[[1]],0.5}],{-1,1}*{-pt1[[1]],0.5}}.(#[[2]]-#[[1]])}}&amp;amp;,#],1]&amp;amp;,{{{0,-1},{0,0}}},gen]},
Graphics[{
{CapForm[&amp;#034;Round&amp;#034;],Gray,Thickness[0.005],Opacity[0.3],Line[{{-0.5,-0.5},{0.5,-0.5}}]},
{CapForm[&amp;#034;Round&amp;#034;],Gray,Thickness[0.005],Line[{{-0.5,0.5},{0.5,0.5}}]},
{(*Tree*)MapIndexed[{Hue[0.022*#2[[1]],0.9,1,0.6],CapForm[&amp;#034;Round&amp;#034;],Thickness[th*0.77^#2[[1]]],Line[#]}&amp;amp;,branches]},
{(*Leaves*)MapIndexed[{Hue[0.03(*gen*),1,1,0.9],CapForm[&amp;#034;Round&amp;#034;],Thickness[th*0.82^(gen+1)],Translate[Line[#],{4,0}]}&amp;amp;,Drop[branches,gen]]},
(*Labels*)
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Scaling Ratio r&amp;#034;,&amp;#034; &amp;#034;&amp;#034;       &amp;#034;&amp;#034; Seed    z = &amp;#034;,y+x*I}],18],Gray],{0,-1.6}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;r = |z|&amp;#034;,&amp;#034; = &amp;#034;,SetAccuracy[Norm[{{pt1[[1]],0.5},{0,0}}],4],&amp;#034;                &amp;#034;,z,&amp;#034; =    &amp;#034;,SetAccuracy[0.5,4]+SetAccuracy[pt1[[1]],4]I}],16],Gray],{0,-1.8}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Angle   \[Theta] = Arg(z)&amp;#034;,&amp;#034; = &amp;#034;,SetAccuracy[VectorAngle[{pt1[[1]],0.5},{0,0.5}],4],&amp;#034; rad = &amp;#034;,SetAccuracy[180/Pi*VectorAngle[{pt1[[1]],0.5},{0,0.5}],2]&amp;#034;\[Degree]         &amp;#034;}],16],Gray],{0,-2}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Hausdorff Dimension \!\(\*SubscriptBox[\(D\), \(H\)]\) = &amp;#034;,SetAccuracy[ Log[2]/Log[1/Norm[{{pt1[[1]],0.5},{0,0}}]],4]}],18],Gray],{4.,-1.6}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Leaves = &amp;#034;,Count[Drop[branches,gen],_Real,\[Infinity]]/4&amp;#034; &amp;#034;&amp;#034;     &amp;#034;&amp;#034;Length = &amp;#034;,SetAccuracy[Count[Drop[branches,gen],_Real,\[Infinity]]/4*(Norm[{{pt1[[1]],0.5},{0,0}}]^gen),3]}],18],Gray],{4.,-1.8}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Lévy Trees       by Bernat Espigulé&amp;#034;}],18],Gray, Opacity[0.4]],{4.,-2}]}},
PlotRange-&amp;gt;{{-2.1,6.1},{-2.1,2.1}},ImageSize-&amp;gt;{1000,600},Background-&amp;gt;Black]],
{{th,0.02,&amp;#034;Thickness&amp;#034;},0.005,0.185},
{{gen,12,&amp;#034;Generations&amp;#034;},Range[1,16], ControlType -&amp;gt; SetterBar},
{{pt1,{0.5,0.5}},{-0.5,0.5},{0.5,0.5},Locator}][/mcode]
[b][size=3]Koch Trees Doodler
[/size][/b]
[img=width: 800px; height: 552px;]/c/portal/getImageAttachment?filename=koch.png&amp;amp;userId=56204[/img]
[mcode]Manipulate[
Module[{branches=NestList[Flatten[Map[{{#[[2]],#[[2]]+{Reverse[{pt1[[1]],-0.5}],{-1,1}*{pt1[[1]],-0.5}}.(#[[2]]-#[[1]])},{#[[2]],#[[2]]+{Reverse[{-pt1[[1]],-0.5}],{-1,1}*{-pt1[[1]],-0.5}}.(#[[2]]-#[[1]])}}&amp;amp;,#],1]&amp;amp;,{{{0,-1},{0,0}}},gen]},
Graphics[{{CapForm[&amp;#034;Round&amp;#034;],Gray,Thickness[0.005],Opacity[0.7],Line[{{-0.5,-0.5},{0.5,-0.5}}]},{CapForm[&amp;#034;Round&amp;#034;],Gray,Opacity[0.3],Thickness[0.005],Line[{{-0.5,0.5},{0.5,0.5}}]},
{(*FrTree*)MapIndexed[{Hue[0.022*#2[[1]],0.9,1,0.6],CapForm[&amp;#034;Round&amp;#034;],Thickness[th*0.75^#2[[1]]],Line[#]}&amp;amp;,branches]},
{(*Red Leaves*)MapIndexed[{Hue[0.03(*gen*),1,1,0.9],CapForm[&amp;#034;Round&amp;#034;],Thickness[th*0.84^(gen+1)],Translate[Line[#],{2,0}]}&amp;amp;,Drop[branches,gen]]},
(*Labels*)
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Scaling Ratio r&amp;#034;,&amp;#034; &amp;#034;&amp;#034;       &amp;#034;&amp;#034; Seed    z = &amp;#034;,y+x*I}],18],Gray],{0,-1.2}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;r = |z|&amp;#034;,&amp;#034; = &amp;#034;,SetAccuracy[Norm[{{pt1[[1]],0.5},{0,0}}],4],&amp;#034;              &amp;#034;,z,&amp;#034; =    &amp;#034;,SetAccuracy[-0.5,4]+SetAccuracy[pt1[[1]],4]I}],16],Gray],{0,-1.4}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Angle   \[Theta] = Arg(z)&amp;#034;,&amp;#034; = &amp;#034;,SetAccuracy[VectorAngle[{pt1[[1]],0.5},{0,0.5}],4],&amp;#034; rad = &amp;#034;,SetAccuracy[180/Pi*VectorAngle[{pt1[[1]],-0.5},{0,0.5}],2]&amp;#034;\[Degree]         &amp;#034;}],16],Gray],{0,-1.6}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Hausdorff Dimension \!\(\*SubscriptBox[\(D\), \(H\)]\) = &amp;#034;,SetAccuracy[ Log[2]/Log[1/Norm[{{pt1[[1]],0.5},{0,0}}]],4]}],18],Gray],{2.,-1.2}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Leaves = &amp;#034;,Count[Drop[branches,gen],_Real,\[Infinity]]/4&amp;#034; &amp;#034;&amp;#034;     &amp;#034;&amp;#034;Length = &amp;#034;,SetAccuracy[Count[Drop[branches,gen],_Real,\[Infinity]]/4*(Norm[{{pt1[[1]],0.5},{0,0}}]^gen),3]}],18],Gray],{2.,-1.4}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Koch Trees       by Bernat Espigulé&amp;#034;}],18],Gray, Opacity[0.4]],{2.,-1.6}]}},
PlotRange-&amp;gt;{{-1.1,3.1},{-1.7,0.5}},ImageSize-&amp;gt;{1000,600},Background-&amp;gt;Black]],
{{th,0.01,&amp;#034;Thickness&amp;#034;},0.005,0.185},
{{gen,12,&amp;#034;Generations&amp;#034;},Range[1,16], ControlType -&amp;gt; SetterBar},
{{pt1,{0.5,0.5}},{-0.5,-0.5},{0.5,-0.5},Locator}][/mcode]
[b][size=3]Polynomial Trees Doodler
[/size][/b]
[img=width: 800px; height: 548px;]/c/portal/getImageAttachment?filename=polynomial.png&amp;amp;userId=56204[/img]
[mcode]Manipulate[
Module[{branches=NestList[Flatten[Map[{{#[[2]],#[[2]]+{Reverse[{pt1[[1]],0.5}],{-1,1}*{pt1[[1]],0.5}}.(#[[2]]-#[[1]])},{#[[2]],#[[2]]+{Reverse[{-pt1[[1]],-0.5}],{-1,1}*{-pt1[[1]],-0.5}}.(#[[2]]-#[[1]])}}&amp;amp;,#],1]&amp;amp;,{{{0,-1},{0,0}}},gen]},
Graphics[{{CapForm[&amp;#034;Round&amp;#034;],Gray,Thickness[0.005],Opacity[0.7],Line[{{-0.5,-0.5},{0.5,-0.5}}]},{CapForm[&amp;#034;Round&amp;#034;],Gray,Thickness[0.005],Line[{{-0.5,0.5},{0.5,0.5}}]},
{(*FrTree*)MapIndexed[{Hue[0.022*#2[[1]],0.9,1,0.6],CapForm[&amp;#034;Round&amp;#034;],Thickness[th*0.8^#2[[1]]],Line[#]}&amp;amp;,branches]},
{(*Red Leaves*)MapIndexed[{Hue[0.03(*gen*),1,1,0.9],CapForm[&amp;#034;Round&amp;#034;],Thickness[th*0.84^(gen+1)],Translate[Line[#],{2,0}]}&amp;amp;,Drop[branches,gen]]},
(*Labels*)
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Scaling Ratio r&amp;#034;,&amp;#034; &amp;#034;&amp;#034;       &amp;#034;&amp;#034; Seed    z = &amp;#034;,y+x*I}],18],Gray],{0,-1.6}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;r = |z|&amp;#034;,&amp;#034; = &amp;#034;,SetAccuracy[Norm[{{pt1[[1]],0.5},{0,0}}],4],&amp;#034;                &amp;#034;,z,&amp;#034; =    &amp;#034;,SetAccuracy[0.5,4]+SetAccuracy[pt1[[1]],4]I}],16],Gray],{0,-1.8}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Angle   \[Theta] = Arg(z)&amp;#034;,&amp;#034; = &amp;#034;,SetAccuracy[VectorAngle[{pt1[[1]],0.5},{0,0.5}],4],&amp;#034; rad = &amp;#034;,SetAccuracy[180/Pi*VectorAngle[{pt1[[1]],0.5},{0,0.5}],2]&amp;#034;\[Degree]         &amp;#034;}],16],Gray],{0,-2}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Hausdorff Dimension \!\(\*SubscriptBox[\(D\), \(H\)]\) = &amp;#034;,SetAccuracy[ Log[2]/Log[1/Norm[{{pt1[[1]],0.5},{0,0}}]],4]}],18],Gray],{2.3,-1.6}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Leaves = &amp;#034;,Count[Drop[branches,gen],_Real,\[Infinity]]/4&amp;#034; &amp;#034;&amp;#034;     &amp;#034;&amp;#034;Length = &amp;#034;,SetAccuracy[Count[Drop[branches,gen],_Real,\[Infinity]]/4*(Norm[{{pt1[[1]],0.5},{0,0}}]^gen),3]}],18],Gray],{2.3,-1.8}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Polynomial Trees       by Bernat Espigulé&amp;#034;}],18],Gray, Opacity[0.4]],{2.3,-2}]}},
PlotRange-&amp;gt;{{-1.7,3.7},{-2.1,1.5}},ImageSize-&amp;gt;{1000,600},Background-&amp;gt;Black]],
{{th,0.025,&amp;#034;Thickness&amp;#034;},0.005,0.185},
{{gen,12,&amp;#034;Generations&amp;#034;},Range[1,16], ControlType -&amp;gt; SetterBar},
{{pt1,{0.5,0.5}},{-0.5,0.5},{0.5,0.5},Locator}][/mcode]
[size=3][b]Jurassic Trees Doodler
[/b][/size]
[img=width: 800px; height: 550px;]/c/portal/getImageAttachment?filename=jurassic.png&amp;amp;userId=56204[/img]
[mcode]Manipulate[
Module[{branches=NestList[Flatten[Map[{{#[[2]],#[[2]]+{Reverse[{pt1[[1]],0.5}],{-1,1}*{pt1[[1]],0.5}}.(#[[2]]-#[[1]])},{#[[2]],#[[2]]+{Reverse[{pt1[[1]],-0.5}],{-1,1}*{pt1[[1]],-0.5}}.(#[[2]]-#[[1]])}}&amp;amp;,#],1]&amp;amp;,{{{0,-1},{0,0}}},gen]},
Graphics[{{CapForm[&amp;#034;Round&amp;#034;],Gray,Thickness[0.005],Opacity[0.7],Line[{{-0.5,-0.5},{0.5,-0.5}}]},{CapForm[&amp;#034;Round&amp;#034;],Gray,Thickness[0.005],Line[{{-0.5,0.5},{0.5,0.5}}]},
{(*FrTree*)MapIndexed[{Hue[0.022*#2[[1]],0.9,1,0.6],CapForm[&amp;#034;Round&amp;#034;],Thickness[th*0.72^#2[[1]]],Line[#]}&amp;amp;,branches]},
{(*Red Leaves*)MapIndexed[{Hue[0.03(*gen*),1,1,0.9],CapForm[&amp;#034;Round&amp;#034;],Thickness[th*0.8^(gen+1)],Translate[Line[#],{2,0}]}&amp;amp;,Drop[branches,gen]]},
(*Labels*)
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Scaling Ratio r&amp;#034;,&amp;#034; &amp;#034;&amp;#034;       &amp;#034;&amp;#034; Seed    z = &amp;#034;,y+x*I}],18],Gray],{0,-1.6}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;r = |z|&amp;#034;,&amp;#034; = &amp;#034;,SetAccuracy[Norm[{{pt1[[1]],0.5},{0,0}}],4],&amp;#034;                &amp;#034;,z,&amp;#034; =    &amp;#034;,SetAccuracy[0.5,4]+SetAccuracy[pt1[[1]],4]I}],16],Gray],{0,-1.8}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Angle   \[Theta] = Arg(z)&amp;#034;,&amp;#034; = &amp;#034;,SetAccuracy[VectorAngle[{pt1[[1]],0.5},{0,0.5}],4],&amp;#034; rad = &amp;#034;,SetAccuracy[180/Pi*VectorAngle[{pt1[[1]],0.5},{0,0.5}],2]&amp;#034;\[Degree]         &amp;#034;}],16],Gray],{0,-2}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Hausdorff Dimension \!\(\*SubscriptBox[\(D\), \(H\)]\) = &amp;#034;,SetAccuracy[ Log[2]/Log[1/Norm[{{pt1[[1]],0.5},{0,0}}]],4]}],18],Gray],{2.3,-1.6}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Leaves = &amp;#034;,Count[Drop[branches,gen],_Real,\[Infinity]]/4&amp;#034; &amp;#034;&amp;#034;     &amp;#034;&amp;#034;Length = &amp;#034;,SetAccuracy[Count[Drop[branches,gen],_Real,\[Infinity]]/4*(Norm[{{pt1[[1]],0.5},{0,0}}]^gen),3]}],18],Gray],{2.3,-1.8}]},
{Inset[Style[Text@TraditionalForm@Style[Row[{&amp;#034;Jurassic Trees       by Bernat Espigulé&amp;#034;}],18],Gray, Opacity[0.4]],{2.3,-2}]}},
PlotRange-&amp;gt;{{-1.7,3.7},{-2.1,1.2}},ImageSize-&amp;gt;{1000,600},Background-&amp;gt;Black]],
{{th,0.03,&amp;#034;Thickness&amp;#034;},0.005,0.185},
{{gen,12,&amp;#034;Generations&amp;#034;},Range[1,16], ControlType -&amp;gt; SetterBar},
{{pt1,{0.5,0.5}},{-0.5,0.5},{0.5,0.5},Locator}][/mcode]
As far as I know these four families of fractal trees have not been presented before so Ive just uploaded them on a single CDF to the Demonstration Project. I will share with you its url when published.

If you would like to explore other demonstrations dealing with these [url=http://mathworld.wolfram.com/DragonCurve.html][i]dragons[/i][/url] here are the links to the [url=http://demonstrations.wolfram.com/PaperfoldingDragonCurve/]Paperfolding Dragon Curve[/url] by [url=http://blog.wolfram.com/author/todd-rowland/]Todd Rowland[/url], the [url=http://demonstrations.wolfram.com/AllPossibleSumsAndDifferencesOfPowers/]original[/url] Polynomial Trees by [url=http://blog.wolfram.com/author/michael-trott/]Michael Trott[/url] (check also his recent posts ([url=http://blog.wolfram.com/2013/05/17/making-formulas-for-everything-from-pi-to-the-pink-panther-to-sir-isaac-newton/]1[/url], [url=http://blog.wolfram.com/2013/07/19/using-formulas-for-everything-from-a-complex-analysis-class-to-political-cartoons-to-music-album-covers/]2[/url], [url=http://blog.wolfram.com/2013/08/15/even-more-formulas-for-everything-from-filled-algebraic-curves-to-the-twitter-bird-the-american-flag-chocolate-easter-bunnies-and-the-superman-solid/]3[/url]) about other creative ways of doodling in Mathematica ), and the classic [url=http://demonstrations.wolfram.com/LimitsOfTreeBranching/]Limits of Tree Branching[/url] by [url=http://blog.wolfram.com/author/stephen-wolfram/]Stephen Wolfram[/url].

[url=http://demonstrations.wolfram.com/PaperfoldingDragonCurve/][img=width: 749px; height: 474px;]/c/portal/getImageAttachment?filename=DragonCurveTodd.jpg&amp;amp;userId=56204[/img]
[/url]
[url=http://demonstrations.wolfram.com/AllPossibleSumsAndDifferencesOfPowers/][img=width: 754px; height: 419px;]/c/portal/getImageAttachment?filename=PolynomialTrott.jpg&amp;amp;userId=56204[/img]
[/url]
[url=http://demonstrations.wolfram.com/LimitsOfTreeBranching/][img=width: 749px; height: 625px;]/c/portal/getImageAttachment?filename=BinaryTreesWolfram.jpg&amp;amp;userId=56204[/img]
[/url]
Finally, if you liked [url=http://blog.wolfram.com/author/theodore-gray/]Theodore Gray[/url]s Tree Bender, here you will find [url=http://pille.iwr.uni-heidelberg.de/~fractaltree01/cdf_binary.html]my adapted CDF[/url] for exploring binary trees with color and with meaningful parameters to describe them precisely.

[url=http://pille.iwr.uni-heidelberg.de/~fractaltree01/cdf_binary.html][img=width: 800px; height: 636px;]/c/portal/getImageAttachment?filename=EspiguleCDF.png&amp;amp;userId=56204[/img][/url]

Thats all for today! Enjoy, and let me know if you had been lucky enough to find [url=http://en.wikipedia.org/wiki/Tree_worship]a tree worthy of worship[/url] ;-). </description>
    <dc:creator>Bernat Espigulé</dc:creator>
    <dc:date>2013-08-27T18:34:31Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/133271">
    <title>A Hands-on Guide to Simulating a Neuron Cable with Wolfram SystemModeler</title>
    <link>https://community.wolfram.com/groups/-/m/t/133271</link>
    <description>This is a sister thread of [url=http://community.wolfram.com/groups/-/m/t/127970?p_p_auth=J7J4xvRC]a discussion about Hodgkin-Huxley cable (HHC) simulation[/url]. I am writing this companion article here to show how to use [url=http://www.wolfram.com/system-modeler/]Wolfram SystemModeler [/url]to recreate this physical system and make it easier to use in the future as black box.&#xD;
  &#xD;
Lets first take a look at my result. The graph on the left is written in Mathematica from this Demonstrations web page:&#xD;
&#xD;
[b][url=http://demonstrations.wolfram.com/TheHodgkinHuxleyEquationsForTransmissionOfElectricalImpulses/]The Hodgkin-Huxley Equations for Transmission of Electrical Impulses along an Axon[/url][/b]&#xD;
&#xD;
[url=http://demonstrations.wolfram.com/TheHodgkinHuxleyEquationsForTransmissionOfElectricalImpulses/][img=width: 637px; height: 547px;]http://demonstrations.wolfram.com/TheHodgkinHuxleyEquationsForTransmissionOfElectricalImpulses/HTMLImages/index.en/popup_3.jpg[/img][/url]&#xD;
&#xD;
 The result on the right hand side from [url=https://github.com/shenghuiy/SystemModelerExamples]my SystemModeler model[/url] (download and unzip everything, open mytest.mo with SystemModeler). The parameters are set with stimulus = 0.142 (mA/cm^2), start time = 1 ms and duration = 40 ms. You can find the two results are identical after you exam the characteristics of the two curves. &#xD;
[center] [img=width: 800px; height: 498px; ]/c/portal/getImageAttachment?filename=systemModeler.png&amp;amp;userId=23928[/img][/center]&#xD;
Of course the Manipuate function in Mathematica is very powerful, yet SystemModeler creates a compoent-like element, which is more convenient to use and more adaptive to a larger set. Another great advantage is that System Modeler encapsulates your code to high level so products should not contain any codes other than the neat blocks or flow charts.[center][img=width: 800px; height: 361px; ]/c/portal/getImageAttachment?filename=Model.png&amp;amp;userId=23928[/img][/center]&#xD;
Though you may be told that you can draw an equivalent circuit to simulate the HHC, we here demonstrate a hardcore-yet-very-general instruction so that you can convert your other Mathematica codes nto a System modeler examples.&#xD;
&#xD;
 [url=http://demonstrations.wolfram.com/TheHodgkinHuxleyEquationsForTransmissionOfElectricalImpulses/]In Faria&amp;#039;s notebook[/url] you may first uncollapse the Initialization Code section. There are many constants defined ahead of the following calcualation. In system modeler I do the following: use keywords &amp;#034;constant&amp;#034; to declare a symbol that is not going to changel; &amp;#034;Real&amp;#034; is simply a type of the symbol, which is like float or doulble in C/C++.[center][img=width: 541px; height: 326px; ]/c/portal/getImageAttachment?filename=constants.png&amp;amp;userId=23928[/img][/center]&#xD;
The next step is to define those intermediate functions. Because these functions are rather simple, I just sneak around and take advantage of variables in SystemModeler to handle these one-argument dependencies. I use &amp;#034;Real am;&amp;#034;, for instance, to delcare such a variable that is indeed a function of V (which in turn depends on time T). In System modeler, a variable is simply a symbol whose value can be changed during computation. [center][img=width: 448px; height: 241px; ]/c/portal/getImageAttachment?filename=varaible.png&amp;amp;userId=23928[/img][/center]&#xD;
After I have declared those symbols, I put all denitions into the equation section. For example, &amp;#034;am[v]&amp;#034; can just be replaced with a algebraic expression with respect to V. This also applies to the rest variables or my original Mathematica function heads.[center][img=width: 800px; height: 669px; ]/c/portal/getImageAttachment?filename=variables2.png&amp;amp;userId=23928[/img][/center]&#xD;
I also notice that the value of V, m, h and n are determined via a system of differential equations. In System Modeler the keyword &amp;#034;der&amp;#034; indicates the first order differential wrt time. It cannot be used recursively, that is No &amp;#034;der(der(x))&amp;#034;.[center][img=width: 300px; height: 195px; ]/c/portal/getImageAttachment?filename=equation.png&amp;amp;userId=23928[/img][/center]&#xD;
I think one of the most featured parts is that I can use GUI to program at same time. The &amp;#034;Modelica.... RealInput&amp;#034; symbols are such drag-drop components. These componts works as a liason so the values inside my axon cable model can talk to other models/blocks and recieve information at the same time. In this case, I just make a copy of the &amp;#034;RealInput&amp;#034; class (dark blue) and &amp;#034;RealOutput&amp;#034; class (white) into my model. If you look closely at the code, you should see a small blue icon on the right end of the framed code block. It is a collapsed symbol for annotation, which contains the coordinates and other graphical info for each compoent when printed on the workspace. [center][img=width: 800px; height: 447px; ]/c/portal/getImageAttachment?filename=interface.png&amp;amp;userId=23928[/img][/center]&#xD;
So far I have walked you through the main process of converting the demonstration project in Mathematica to Systemmodeler language. You can[url=https://github.com/shenghuiy/SystemModelerExamples] download the entire model[/url] with a compiled experimental file, *.sme file. With either option, you need to hit the play button to run the experiment and uncollapse the argument list to pick up the output you want to see in the plot, just like the attachment below. [center][img=width: 800px; height: 741px; ]/c/portal/getImageAttachment?filename=ScreenShot2013-10-02at12.49.04AM.png&amp;amp;userId=23928[/img][/center]&#xD;
&#xD;
Certainly I left you something to explore such as how to add a picture into the model. Since you have my model, you can spend some time to work around and explore the new things as an essential part of learning. &#xD;
&#xD;
Ref. &#xD;
The big and juicy picure of the neuron cell which I used in the model is [url=http://www.studyblue.com/notes/note/n/nervous-tissue-and-fundamentals/deck/1448672]from this web page[/url]. </description>
    <dc:creator>Shenghui Yang</dc:creator>
    <dc:date>2013-10-02T06:07:53Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/227651">
    <title>Convergence of synonym networks</title>
    <link>https://community.wolfram.com/groups/-/m/t/227651</link>
    <description>Take a word and find its synonyms. Then find the synonyms of the synonyms from the previous step. And so on. [b]For how long will the number of synonyms continue to grow?[/b]

Language structures can take peculiar shapes. Code can be quite simple to compute and automate informative visualizations. Below vertex size is larger if the vertex has more connections, meaning a word has a greater number of synonyms. Note GraphLayout -&amp;gt; {&amp;#034;BalloonEmbedding&amp;#034;, &amp;#034;RootVertex&amp;#034; -&amp;gt; word} option to Graph is used to produce this specific layout. The code below is based on [url=http://wolfram.com/xid/0j49p2ci-ckbtad]an example from Documentation[/url].

Lets define a function:[mcode]SynonymNetwork[word_String, depth_Integer, labels_: Tooltip] :=
 
 Module[{ed, sz, g},
  
  (* list of edges *)
   ed = Union[Sort /@ Flatten[Rest[NestList[Union[Flatten[
           Thread[# &amp;lt;-&amp;gt; WordData[#, &amp;#034;Synonyms&amp;#034;, &amp;#034;List&amp;#034;]] &amp;amp; /@ #[[All, 2]]]] &amp;amp;, {&amp;#034;&amp;#034; &amp;lt;-&amp;gt; word}, depth]]]];
  
  (* size of vertices based on number of synonyms *)
   sz = Thread[VertexList[Graph[ed]] -&amp;gt; Map[{&amp;#034;Scaled&amp;#034;, #} &amp;amp;, 
           .05 (.01 + .99 N[Rescale[VertexDegree[g = Graph[ed]]]])^.5]];
  
  (* graph *)  
  SetProperty[g, 
   {GraphLayout -&amp;gt; {&amp;#034;BalloonEmbedding&amp;#034;, &amp;#034;RootVertex&amp;#034; -&amp;gt; word}, 
    EdgeStyle -&amp;gt; Directive[Opacity[.2], Red], 
    VertexStyle -&amp;gt; Directive[Opacity[.1], Black], 
    VertexStyle -&amp;gt; {word -&amp;gt; Directive[Opacity[1], Red]}, 
    VertexSize -&amp;gt; sz, VertexLabels -&amp;gt; Placed[&amp;#034;Name&amp;#034;, labels]}]
  
  ][/mcode]
Here how it works:[mcode]SynonymNetwork[&amp;#034;promise&amp;#034;, 3][/mcode]
[img=width: 479px; height: 727px;]/c/portal/getImageAttachment?filename=qw23rf5tef5gtbj7uyjthd.gif&amp;amp;userId=11733[/img]


Now as I asked earlier: will the number of synonyms continue to grow? This of course depends on a particular thesaurus dictionary at hand. But once we settled on one, what can we find? Obviously some very specific words have no synonyms at all:
[mcode]In[1]:= WordData[&amp;#034;transmogrification&amp;#034;, &amp;#034;Definitions&amp;#034;]
Out[1]= {{&amp;#034;transmogrification&amp;#034;, &amp;#034;Noun&amp;#034;} -&amp;gt; 
          &amp;#034;the act of changing into a different form or appearance (especially a fantastic or grotesque one)&amp;#034;}


In[2]:= WordData[&amp;#034;transmogrification&amp;#034;, &amp;#034;Synonyms&amp;#034;]
Out[2]= {{&amp;#034;transmogrification&amp;#034;, &amp;#034;Noun&amp;#034;} -&amp;gt; {}}[/mcode]
Some words will have very trivial small finite networks (note network depth is set 20, while even 100 or greater will not change it):[mcode]SynonymNetwork[&amp;#034;chemistry&amp;#034;, 20, Above][/mcode]
[img=width: 327px; height: 356px;]/c/portal/getImageAttachment?filename=sdf34erfdd43ergf.png&amp;amp;userId=11733[/img]

And of course many words will have networks that grow very fast. This applies not only for very general words such as fast or beautiful, but also for strange rare words such as &amp;#034;discombobulate&amp;#034;:[mcode]ParallelMap[Length[EdgeList[SynonymNetwork[&amp;#034;discombobulate&amp;#034;, #]]] &amp;amp;, Range[16]]
Out[]= {9, 97, 1097, 7644, 26051, 46671, 59440, 65187, 67805, 68798, 69274, 69456, 69565, 69587, 69592, 69592}

data = ParallelMap[Length[VertexList[SynonymNetwork[&amp;#034;discombobulate&amp;#034;, #]]] &amp;amp;, Range[16]
{10, 73, 787, 4293, 11646, 18858, 22931, 24911, 25743, 26096, 26238, 26302, 26321, 26330, 26330, 26330}

ListPlot[data, Filling -&amp;gt; Bottom, Joined -&amp;gt; True, Mesh -&amp;gt; All, AxesLabel -&amp;gt; {&amp;#034;Network depth&amp;#034;, &amp;#034;Synonyms&amp;#034;}][/mcode]
[img=width: 450px; height: 244px;]/c/portal/getImageAttachment?filename=ScreenShot2014-03-31at1.44.27AM.png&amp;amp;userId=11733[/img]


So we see [b]&amp;#034;discombobulate&amp;#034; synonym network gets saturated at depth 15 and attains 26330 vertices and 69592 edges[/b]. Quite magnificent result I think ;-) This is, btw, very inefficient way of computing the convergence  we repeat same computations many times while building the graph. Ideally we should introduce counting synonyms part into our SynonymNetwork function. This is how discombobulate network looks &amp;#034;big&amp;#034; already at depth 3:
[mcode]SynonymNetwork[&amp;#034;discombobulate&amp;#034;, 3]
[/mcode][img]/c/portal/getImageAttachment?filename=df45t6576rteyrsgdfaaasdf.png&amp;amp;userId=11733[/img]

How big do such networks get? Can we make some estimates? Well, lets first define set of all words that to belong to discombobulate network:[mcode]gr = SynonymNetwork[&amp;#034;discombobulate&amp;#034;, 15];
ver = VertexList[gr];[/mcode]
Then lets find all unique words in Alice in Wonderland:[mcode]alice = Union[ToLowerCase[StringSplit[ExampleData[{&amp;#034;Text&amp;#034;, &amp;#034;AliceInWonderland&amp;#034;}], RegularExpression[&amp;#034;[\\W_]+&amp;#034;]]]];
alice // Length

Out[]= 1484[/mcode]
Then select, say, only nouns that have synonyms [mcode]nouns = Select[alice, MemberQ[WordData[#, &amp;#034;PartsOfSpeech&amp;#034;], &amp;#034;Noun&amp;#034;] &amp;amp;&amp;amp; WordData[#, &amp;#034;Synonyms&amp;#034;, &amp;#034;List&amp;#034;] =!= {} &amp;amp;];
nouns // Length

Out[]= 809[/mcode]
We see that more than half of these nouns belong to the discombobulate network:
[mcode]MemberQ[ver, #] &amp;amp; /@ nouns // Tally
Out[]= {{False, 223}, {True, 586}}[/mcode]
I also would like to share some beautiful smaller CONVERGED (saturated) networks, which I found, - beautiful in structure and sets of words they gather (see below). They of course do not belong to huge &amp;#034;discombobulate&amp;#034; graph above. And as already mentioned I propose the following - comment if:
[list]
[*]you find some beautiful networks 
[*]you can figure out how we can make estimates on large networks or do any further digging 
[*]you can optimize code
[*]you have any ideas / comments at all ;-)
[/list]
[b]===&amp;gt; &amp;#034;dragonfly&amp;#034; - 23 synonyms, depth 3[/b]

[mcode]ParallelMap[Length[VertexList[SynonymNetwork[&amp;#034;dragonfly&amp;#034;, #]]] &amp;amp;, Range[7]]
Out[]= {8, 14, 23, 23}

SynonymNetwork[&amp;#034;dragonfly&amp;#034;, 20, Above][/mcode]
[img]/c/portal/getImageAttachment?filename=sdf43sfs7s683sdfs8239sf.png&amp;amp;userId=11733[/img]

[b]===&amp;gt; &amp;#034;benevolent&amp;#034; - 27 synonyms, depth 7[/b]

[mcode]ParallelMap[Length[VertexList[SynonymNetwork[&amp;#034;benevolent&amp;#034;, #]]] &amp;amp;, Range[9]]
Out[]= {11, 15, 19, 23, 25, 26, 27, 27}

SynonymNetwork[&amp;#034;benevolent&amp;#034;, 20, Below][/mcode]
[img]/c/portal/getImageAttachment?filename=GMLO35FVFVFDffdfdzg.png&amp;amp;userId=11733[/img]</description>
    <dc:creator>Vitaliy Kaurov</dc:creator>
    <dc:date>2014-03-30T05:26:37Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/863933">
    <title>Walking strandbeest dynamics</title>
    <link>https://community.wolfram.com/groups/-/m/t/863933</link>
    <description>Many of you have seen the strandbeest (from Dutch, meaning beach-beast). These PVC tube animals created by Theo Jansen walk along the beach and are wind powered:&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
Years ago (2009 to be more exact) I made a post on my blog about the movement of the legs, as evidenced by the still-nicely-working Mathematica notebook:&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
At the time the proportions of the legs were not known publicly so I meticulously studied frames of (low quality) YouTube videos. I made the following diagram in Illustrator of what I thought I saw:&#xD;
&#xD;
![enter image description here][3] ![enter image description here][4]&#xD;
&#xD;
On the left the length of the legs in red, and in blue the numbers of the joints. On the right the trajectory of the joints that I calculated at the time in Mathematica. It&amp;#039;s funny that my blog does not exist any more (for years actually), but these images live on, as I found out when I looked for strandbeest on Google Images:&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
My images! But not on my website! Nice to see people still use it. Now, in 2016, I saw these files on my laptop, and thought: is there finally more known about them? Well yes, there is! The exact proportions are now known and there is tons and tons of videos, lectures, 3D-printable strandbeest models, interviews with Theo Jansen and other stuff! So now we can find the exact dimensions readily on the internet:&#xD;
&#xD;
![enter image description here][6] &#xD;
&#xD;
Notice that I (wrongly) assumed that the legs had &amp;#039;feet&amp;#039;! oops! I was very happy to see that my lengths were not that wrong though! Let&amp;#039;s recreate the strandbeest. We do so by first creating a function that quickly finds the intersection of two circles:&#xD;
&#xD;
    Clear[FindPoint, FindLines]&#xD;
    FindPoint[p1 : {x1_, y1_}, p2 : {x2_, y2_}, R_, r_, side_] := Module[{d, x, y, vc1, vc2, p, sol, sol1, sol2, s1, s2, sr},&#xD;
      d = N@Sqrt[(x2 - x1)^2 + (y2 - y1)^2];&#xD;
      x = (d^2 - r^2 + R^2)/(2 d);&#xD;
      y = Sqrt[R^2 - x^2];&#xD;
      vc1 = Normalize[{x2 - x1, y2 - y1}];&#xD;
      vc2 = Cross[vc1];&#xD;
      p = {x1, y1} + x vc1;&#xD;
      {sol1, sol2} = {p + y vc2, p - y vc2};&#xD;
      s1 = Sign[Last[Cross[Append[(p2 - p1), 0], Append[(sol1 - p1), 0]]]];&#xD;
      s2 = Sign[Last[Cross[Append[(p2 - p1), 0], Append[(sol2 - p1), 0]]]];&#xD;
      sr = If[side === Left, 1, -1];&#xD;
      Switch[sr, s1,&#xD;
       sol1&#xD;
       ,&#xD;
       s2&#xD;
       ,&#xD;
       sol2&#xD;
       ]&#xD;
      ]&#xD;
&#xD;
This finds on the side &amp;#039;side&amp;#039; (Left/Right) the intersection point of two circles positioned at p1 and p2, with radii R and r, respectively. And now we can easily compute all the little vertices/joints of our beast:&#xD;
&#xD;
    FindLines[\[Theta]_] := Module[{p1, p2, p3, p4, p5, p6, p7, p8, p10, p11, p12, p13, p14, p15},&#xD;
      {p1, p2, p3, p4, p5, p6, p7, p8, p10, p11, p12, p13, p14, p15} = FindPoints[\[Theta]];&#xD;
      {{p1, p2}, {p2, p3}, {p3, p4}, {p1, p4}, {p2, p6}, {p4, p6}, {p3, p5}, {p4, p5}, {p5, p8}, {p6, p8}, {p6, p7}, {p7, p8}, {p1, &#xD;
        p11}, {p10, p11}, {p2, p10}, {p2, p13}, {p11, p13}, {p10, p12}, {p11, p12}, {p12, p14}, {p13, p14}, {p13, p15}, {p14, p15}}&#xD;
      ]&#xD;
    FindPoints[\[Theta]_] := Module[{p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16},&#xD;
      p1 = {0, 0};&#xD;
      p4 = {38, -7.8};&#xD;
      p11 = {-38, -7.8};&#xD;
      p2 = 15 {Cos[\[Theta]], Sin[\[Theta]]};&#xD;
      &#xD;
      p3 = FindPoint[p2, p4, 50, 41.5, Left];&#xD;
      p6 = FindPoint[p2, p4, 61.9, 39.3, Right];&#xD;
      p5 = FindPoint[p3, p4, 55.8, 41.5, Left];&#xD;
      p8 = FindPoint[p5, p6, 39.4, 36.7, Left];&#xD;
      p7 = FindPoint[p6, p8, 49, 65.7, Right];&#xD;
      &#xD;
      p10 = FindPoint[p2, p11, 50, 41.5, Right];&#xD;
      p13 = FindPoint[p2, p11, 61.9, 39.3, Left];&#xD;
      p12 = FindPoint[p10, p11, 55.8, 41.5, Right];&#xD;
      p14 = FindPoint[p12, p13, 39.4, 36.7, Right];&#xD;
      p15 = FindPoint[p13, p14, 49, 65.7, Left];&#xD;
      &#xD;
      {p1, p2, p3, p4, p5, p6, p7, p8, p10, p11, p12, p13, p14, p15}&#xD;
      ]&#xD;
&#xD;
Now we can plot it easily:&#xD;
&#xD;
    trajectoriesdata = (FindPoints /@ Subdivide[0, 2 Pi, 100])\[Transpose];&#xD;
    Manipulate[&#xD;
      Graphics[{Arrowheads[Large], Arrow /@ trajectoriesdata, Thick, Red, Line[FindLines[\[Theta]]]},&#xD;
       PlotRange -&amp;gt; {{-150, 150}, {-120, 70}}, &#xD;
       ImageSize -&amp;gt; 800&#xD;
      ]&#xD;
     ,&#xD;
     {\[Theta], 0, 2 \[Pi]}&#xD;
    ]&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
We can also make an entire bunch of legs at the same time and make a 3D beast!&#xD;
&#xD;
    Manipulate[&#xD;
     mp = 60;&#xD;
     n = 12;&#xD;
     \[CurlyPhi] = Table[Mod[5 \[Iota], n, 1], {\[Iota], 1, n}];&#xD;
     Graphics3D[{Darker@Yellow, Table[&#xD;
        Line[ &#xD;
         Map[Prepend[mp \[Iota]], &#xD;
          FindLines[\[Theta] + \[CurlyPhi][[\[Iota]]] (2 Pi/n)], {2}]],&#xD;
        {\[Iota], n}&#xD;
        ]&#xD;
       , Black, Line[{{mp 1, 0, 0}, {mp n, 0, 0}}]&#xD;
       }&#xD;
      ,&#xD;
      Lighting -&amp;gt; &amp;#034;Neutral&amp;#034;,&#xD;
      PlotRangePadding -&amp;gt; Scaled[.1],&#xD;
      PlotRange -&amp;gt; {{-mp, (n + 1) mp}, {-150, 150}, {-150, 150}},&#xD;
      Boxed -&amp;gt; False,&#xD;
      ImageSize -&amp;gt; 700&#xD;
      ]&#xD;
     ,&#xD;
     {\[Theta], 0, 2 \[Pi]}&#xD;
     ]&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
From the side we can look at how the legs of 4-pair-legged and 6-pair-legged versions of the beasts work:&#xD;
&#xD;
![enter image description here][9] ![enter image description here][10]&#xD;
&#xD;
Hope you enjoyed this! Perhaps someone else can make this thing actually walk over a (bumpy) surface?&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=LVDKumerus2.jpg&amp;amp;userId=73716&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2016-05-29at00.51.53.png&amp;amp;userId=73716&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=strandbeest_sketch.png&amp;amp;userId=73716&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=strandbeest_trajectories.png&amp;amp;userId=73716&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2016-05-29at00.16.23.png&amp;amp;userId=73716&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Strandbeest_Leg_Proportions-01.png&amp;amp;userId=73716&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=3493strandwalk.gif&amp;amp;userId=73716&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=3587strandwalk3D.gif&amp;amp;userId=73716&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=4legged.gif&amp;amp;userId=73716&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=6legged.gif&amp;amp;userId=73716</description>
    <dc:creator>Sander Huisman</dc:creator>
    <dc:date>2016-05-28T23:02:16Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/33771">
    <title>Visibility Graphs: Dualism of Time Series and Networks</title>
    <link>https://community.wolfram.com/groups/-/m/t/33771</link>
    <description>From a recent Complex System article [1] I found out about interesting mapping between Graphs and Time Series that currently gaining more and more attention. The main idea is being able to apply time series analysis methods to networks and vice versa. There is a hope of gaining new insights into familiar objects by approaching from different side. I thought it would be interesting to implement a toy example in Mathematica. I consider the simplest Horizontal Visibility Graph (HVG) algorithm which can be simply explained with the figure below.&#xD;
&#xD;
[img]http://i.imgur.com/uK2jT.png[/img]&#xD;
&#xD;
   1. Every event in time series correspond to a vertex in the graph&#xD;
   2. Two events are connected by edge in the graph if all events between them in time series a smaller then them in magnitude&#xD;
&#xD;
There are other more complex mapping algorithms (see references at the end), but well stick with this simple one. Lets consider three different types of time series to see what kind of networks they can produce:&#xD;
   1. Deterministic system: Cellular Automaton rule 54 with complex type 4 behavior&#xD;
   2. Stochastic system: Geometric Brownian Motion random process&#xD;
   3. Empirical system: Financial data of GE stock price&#xD;
[mcode]dataS = {FromDigits[#, 2] &amp;amp; /@ &#xD;
   CellularAutomaton[54, RandomInteger[1, 200], 49],&#xD;
   RandomFunction[GeometricBrownianMotionProcess[0, .1, 2], {1, 50, 1}][[2, 1, 1]],&#xD;
   FinancialData[&amp;#034;GE&amp;#034;, &amp;#034;Jan. 1, 2000&amp;#034;][[All, 2]][[1 ;; 50]]};&#xD;
&#xD;
ListPlot[#, Filling -&amp;gt; Bottom, AspectRatio -&amp;gt; 1/10, FillingStyle -&amp;gt; Thick, PlotStyle -&amp;gt; PointSize[.008], &#xD;
Axes -&amp;gt; {True, False}, GridLines -&amp;gt; {None, Automatic}, Ticks -&amp;gt; {Range[81], None}, ImageSize -&amp;gt; 800] &amp;amp; /@ dataS&#xD;
[/mcode]&#xD;
[img]http://i.imgur.com/aI72Q.png[/img]&#xD;
Define the mapping function&#xD;
[mcode]fied[m_, n_, data_] := If[(Min[#[[m]], #[[n]]] &amp;gt; Max[#[[m + 1 ;; n - 1]]]) &amp;amp;@data, m \[UndirectedEdge] n][/mcode]Compute the edges of the graph&#xD;
[mcode]edgesS = Cases[Flatten[Table[fied[m, n, #], {m, Length[#]}, {n, m + 1, Length[#]}]], _ \[UndirectedEdge] _] &amp;amp; /@ dataS;[/mcode]Build the graph and highlight vertexes based on vertex degree and the shortest path between initial and final events. &#xD;
[mcode]gS = Graph[#, GraphLayout -&amp;gt; &amp;#034;LayeredDigraphEmbedding&amp;#034;] &amp;amp; /@ edgesS;&#xD;
gSH = HighlightGraph[#, VertexList[#],&#xD;
VertexSize -&amp;gt; Thread[VertexList[#] -&amp;gt; Rescale[VertexDegree[#]]],&#xD;
ImageSize -&amp;gt; {Automatic, 500}, VertexLabels -&amp;gt; &amp;#034;Name&amp;#034;] &amp;amp; /@ gS;&#xD;
&#xD;
HighlightGraph[#, PathGraph[FindShortestPath[#, 1, 50]], GraphHighlightStyle -&amp;gt; &amp;#034;Thick&amp;#034;] &amp;amp; /@ gSH[/mcode][img]http://i.imgur.com/2bQU6.png[/img]&#xD;
I used LayeredDigraphEmbedding which kind of preserves chronological order of the series laying out networks nicely. I hope you enjoyed this little mapping and may apply a similar method for your own research. There are inverse mappings too - see the reference. Please feel free to share your ideas on the subject or possible algorithm optimization. &#xD;
&#xD;
   [1] [b][url=http://www.complex-systems.com/abstracts/v21_i03_a03.html]Discriminating Chaotic Visibility Graph Eigenvalues, Vincenzo Fioriti et al, Complex Systems, Vol 21, No 3, p193[/url][/b]&#xD;
   [2] [b][url=http://www.pnas.org/content/105/13/4972.full]From time series to complex networks: The visibility graph[/url][/b]&#xD;
   [3] [b][url=http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3154932/pdf/pone.0023378.pdf]Duality between Time Series and Networks[/url][/b]&#xD;
   [4] [b][url=http://arxiv.org/find/all/1/AND+abs:+AND+visibility+graph+abs:+AND+time+series/0/1/0/all/0/1?skip=0&amp;amp;query_id=701ef182d80b670f]Some related arXiv.org papers[/url][/b]</description>
    <dc:creator>Vitaliy Kaurov</dc:creator>
    <dc:date>2013-01-17T03:13:27Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/546818">
    <title>Given an exact formula get probability distribution with matching PDF?</title>
    <link>https://community.wolfram.com/groups/-/m/t/546818</link>
    <description>[Crossposting][1] here to get a wider opinion. So, given some data, *Mathematica* 10.2 can now attempt to figure out what probability distribution might have produced it. Cool! But suppose that, instead of having data, we have something that is in some ways better -- a formula. Let&amp;#039;s call it $f$. We suspect -- perhaps because $f$ is non-negative over some domain and because the integral of $f$ over that domain is 1 --  that $f$ is actually the PDF of some distribution (Normal, Lognormal, Gamma, Weibull, etc.) or some relatively simple transform of that distribution. &#xD;
&#xD;
Is there any way that *Mathematica* can help figure out the distribution (or simple transform) whose PDF is the same as $f$?&#xD;
&#xD;
Example: Consider the following formula:&#xD;
&#xD;
    1/(2*E^((-m + Log[5])^2/8)*Sqrt[2*Pi])&#xD;
&#xD;
$$\frac{e^{-\frac{1}{8} (\log (5)-m)^2}}{2 \sqrt{2 \pi }}$$&#xD;
&#xD;
As it happens -- and as I discovered with some research and guesswork -- this formula is the PDF of `NormalDistribution[Log[5], 2]` evaluated at $m$. But is there a better way than staring or guessing to discover this fact?  That is, help me write `FindExactDistribution[f_, params_]`.&#xD;
&#xD;
Notes&#xD;
---&#xD;
&#xD;
 - The motivation for the problem comes from thinking about Conjugate Prior distributions but I suspect it might have a more general application. &#xD;
&#xD;
 - One could start with mapping PDF evaluated at $m$ over a variety of continuous distributions.  And if I did this I would at some point get to what I will call $g$, which is the PDF or the `NormalDistribution` with parameters $a$ and $b$ evaluated at $m$.&#xD;
&#xD;
        1/(b*E^((-a + m)^2/(2*b^2))*Sqrt[2*Pi])&#xD;
&#xD;
$$\frac{e^{-\frac{(m-a)^2}{2 b^2}}}{\sqrt{2 \pi } b}$$&#xD;
&#xD;
But unless I knew that if I replaced $a$ by `Log[5]` and $b$ by $2$ that I would get $f$, this fact would not mean a lot to me. I suppose I could look at the `TreeForm` of $f$ and $g$ and I would notice certain similarities, and that might be a hint, but I am not sure how to make much progress beyond that observation. Ultimately, the problem looks to be about finding substitutions in parts of a tree ($g$) which, after evaluation, yield a tree that matches a target $f$. I have the suspicion that this is a difficult problem with an NKS flavor but one for which *Mathematica* and its ability to transform expressions might be well suited.&#xD;
&#xD;
&#xD;
  [1]: http://mathematica.stackexchange.com/q/91408/13</description>
    <dc:creator>Seth Chandler</dc:creator>
    <dc:date>2015-08-12T18:27:19Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1065956">
    <title>Computational Lichtenberg figures</title>
    <link>https://community.wolfram.com/groups/-/m/t/1065956</link>
    <description>![enter image description here][1]&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][2]&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=lichtenberg.gif&amp;amp;userId=32203&#xD;
  [2]: https://www.wolframcloud.com/obj/2775a340-5dcd-445e-8949-2d92d2fa1aed</description>
    <dc:creator>Henrik Schachner</dc:creator>
    <dc:date>2017-04-19T10:34:55Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/392391">
    <title>Fractal Fun: Tweet-a-Program Mandelbrot Code Challenge</title>
    <link>https://community.wolfram.com/groups/-/m/t/392391</link>
    <description>This week Wolfram is celebrating Benoit Mandelbrots birthday and his contributions to mathematics by holding a [Tweet-a-Program challenge][1]. In honor of Mandelbrot, tweet us your favorite fractal-themed lines of Wolfram Language code.&#xD;
&#xD;
To give you some ideas, I&amp;#039;ve listed below my favorite examples of WL-generated fractals:&#xD;
&#xD;
 1. [ Fractal Self-Portrait, The Mandelbrot Set:][2]&#xD;
&#xD;
![Fractal Self-Portrait, The Mandelbrot Set][3]&#xD;
&#xD;
 2. [A Binary Fractal Hand:][4]&#xD;
&#xD;
![The Fractal Hand][5]&#xD;
&#xD;
 3. [A MandelTree:][6]&#xD;
&#xD;
![MandelTree][7]&#xD;
&#xD;
 4. [Dalí&amp;#039;s Face of War:][8]  (For comparison with the next graphic.) &#xD;
&#xD;
![The Face of War][9]&#xD;
&#xD;
 5. [The WL Face of War:][10]&#xD;
&#xD;
![WL Face of War][11]&#xD;
&#xD;
 6. [A Cool Julia Set:][12]&#xD;
&#xD;
![Julia Set][13]&#xD;
&#xD;
 7. [The Glynn Set Tree:][14]&#xD;
&#xD;
![Glynn Set][15]&#xD;
&#xD;
 8. [The Jurassic Park Fractal Dragon in 3D:][16]&#xD;
&#xD;
![Jurassic Dragon][17]&#xD;
&#xD;
 9. [A Plane-Filling H-Fractal in 3D:][18]&#xD;
&#xD;
![HTree][19]&#xD;
&#xD;
 10. [The GoldenRatio Icosahedron Fractal:][20]&#xD;
&#xD;
![Icosahedron Fractal][21]&#xD;
&#xD;
 11. [My Golden Fractal Tree Gasket:][22]&#xD;
&#xD;
![enter image description here][23]&#xD;
&#xD;
Read about its discovery in [Adventures into the Mathematical Forest of Fractal Trees][24].&#xD;
&#xD;
 12. [A Five-Armed Spiral Galaxy:][25]&#xD;
&#xD;
![Fractal Galaxy][26]&#xD;
&#xD;
 13. [The Koch Snowflake Tree:][27]&#xD;
&#xD;
![Koch Snowflake][28]&#xD;
&#xD;
 14. [A Binary Tree:][29]&#xD;
&#xD;
![Binary Tree][30]&#xD;
&#xD;
 15. [A Sierpinski Triangle Tree:][31]&#xD;
&#xD;
![Sierpinski Triangle Tree][32]&#xD;
&#xD;
 16. [A Plane-Filling Tree:][33]&#xD;
&#xD;
![Plane-Filling Tree][34]&#xD;
&#xD;
 17. [And My Tetrahedron Sierpinski Tree:][35]&#xD;
&#xD;
![Tetrahedron Tree][36]&#xD;
&#xD;
I hope that these examples captured your imagination. I cant wait to see what you come up with!&#xD;
&#xD;
[Bernat Espigulé][37]&#xD;
&#xD;
&#xD;
  [1]: http://blog.wolfram.com/2014/11/17/fractal-fun-tweet-a-program-mandelbrot-code-challenge/&#xD;
  [2]: https://twitter.com/wolframtap/status/535021140331474944&#xD;
  [3]: /c/portal/getImageAttachment?filename=B2zG5GjIIAA1Xw0.png&amp;amp;userId=56204&#xD;
  [4]: https://twitter.com/wolframtap/status/515634587045986304&#xD;
  [5]: /c/portal/getImageAttachment?filename=Byfm7L8IQAAO3oO.png&amp;amp;userId=56204&#xD;
  [6]: https://twitter.com/wolframtap/status/534493892423725056&#xD;
  [7]: /c/portal/getImageAttachment?filename=B2rnXO-IQAEr24Z.png&amp;amp;userId=56204&#xD;
  [8]: https://twitter.com/wolframtap/status/528515298534912000&#xD;
  [9]: /c/portal/getImageAttachment?filename=B1Wp3RjIYAAzj7y.png&amp;amp;userId=56204&#xD;
  [10]: https://twitter.com/wolframtap/status/528518367683280898&#xD;
  [11]: /c/portal/getImageAttachment?filename=B1Wsp7FIQAAIGRD.png&amp;amp;userId=56204&#xD;
  [12]: https://twitter.com/wolframtap/status/515650970081312768&#xD;
  [13]: /c/portal/getImageAttachment?filename=Byf10j4IAAA5Tc8.png&amp;amp;userId=56204&#xD;
  [14]: https://twitter.com/wolframtap/status/515522896861876224&#xD;
  [15]: /c/portal/getImageAttachment?filename=ByeBV8XIQAA3ZY6.png&amp;amp;userId=56204&#xD;
  [16]: https://twitter.com/wolframtap/status/522014262546685952&#xD;
  [17]: /c/portal/getImageAttachment?filename=Bz6RNLPIMAAtO5g.png&amp;amp;userId=56204&#xD;
  [18]: https://twitter.com/wolframtap/status/518189735454732288&#xD;
  [19]: /c/portal/getImageAttachment?filename=BzD60ZgIAAA5_5R.png&amp;amp;userId=56204&#xD;
  [20]: https://twitter.com/wolframtap/status/534708482541637635&#xD;
  [21]: /c/portal/getImageAttachment?filename=B2uqiBPIEAArX5z.png&amp;amp;userId=56204&#xD;
  [22]: https://twitter.com/wolframtap/status/530054886143307778&#xD;
  [23]: /c/portal/getImageAttachment?filename=B1siHEPIQAEPnyY.png&amp;amp;userId=56204&#xD;
  [24]: http://blog.wolfram.com/2014/05/22/adventures-into-the-mathematical-forest-of-fractal-trees/&#xD;
  [25]: https://twitter.com/wolframtap/status/531835478933520384&#xD;
  [26]: /c/portal/getImageAttachment?filename=B2F1jMqIMAAiPrv.png&amp;amp;userId=56204&#xD;
  [27]: https://twitter.com/wolframtap/status/530358766928416769&#xD;
  [28]: /c/portal/getImageAttachment?filename=B1w2fQUIcAAv4rl.png&amp;amp;userId=56204&#xD;
  [29]: https://twitter.com/wolframtap/status/534693936347234304&#xD;
  [30]: /c/portal/getImageAttachment?filename=B2udTVJIcAA2jfo.png&amp;amp;userId=56204&#xD;
  [31]: https://twitter.com/wolframtap/status/534694842941833216&#xD;
  [32]: /c/portal/getImageAttachment?filename=B2ueIGIIMAEhWvN.png&amp;amp;userId=56204&#xD;
  [33]: https://twitter.com/wolframtap/status/534699490855645184&#xD;
  [34]: /c/portal/getImageAttachment?filename=B2uiWoPIEAAO9dt.png&amp;amp;userId=56204&#xD;
  [35]: https://twitter.com/wolframtap/status/534686739848499200&#xD;
  [36]: /c/portal/getImageAttachment?filename=B2uWwb7IMAAJzOW.png&amp;amp;userId=56204&#xD;
  [37]: https://twitter.com/bernatree</description>
    <dc:creator>Bernat Espigulé</dc:creator>
    <dc:date>2014-11-19T12:45:24Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/595870">
    <title>Ocean currents: from Fukushima and rubbish, to Malaysian airplane MH370</title>
    <link>https://community.wolfram.com/groups/-/m/t/595870</link>
    <description>![Ocean currents: from Fukushima and rubbish, to Malaysian airplane MH370][1]&#xD;
&#xD;
In this post I will use data from NASA&amp;#039;s ECCO2 project (http://ecco2.jpl.nasa.gov/) to simulate various scenarios: the movement of radioactive particles from the Fukushima nuclear power plant and the accumulation of rubbish in the oceans. I download about 20 years worth of oceanographic data and study how the flow of water might transport particles. A slight modification of the program might be useful to determine the crash site of Malaysian airplane MH370. The work was done with [Bjoern Schelter][2], who is member of this community. &#xD;
&#xD;
We will first download the vector fields for u and v direction. We obtain data for different depth, but I will only use surface currents. We first generate a list of filenames.&#xD;
&#xD;
    filenamesU = (&amp;#034;http://ecco2.jpl.nasa.gov/opendap/data1/cube/cube92/lat_lon/quart_90S_90N/UVEL.nc/UVEL.1440x720x50.&amp;#034; &amp;lt;&amp;gt; # &amp;lt;&amp;gt; &amp;#034;.nc.ascii?UVEL[0:1:0][0:1:0][0:1:719][0:1:1439]&amp;#034; &amp;amp; /@ (StringJoin[{ToString[#[[1]]], StringTake[StringJoin[ToString /@ PadLeft[{#[[2]]}, 2]], -2], StringTake[StringJoin[ToString /@ PadLeft[{#[[3]]}, 2]], -2]}] &amp;amp; /@ Table[Normal[DatePlus[DateObject[{1992, 1, 2}], 3*n]], {n, 0, 2556}]));&#xD;
    &#xD;
    filenamesV = (&amp;#034;http://ecco2.jpl.nasa.gov/opendap/data1/cube/cube92/lat_lon/quart_90S_90N/VVEL.nc/VVEL.1440x720x50.&amp;#034; &amp;lt;&amp;gt; # &amp;lt;&amp;gt; &amp;#034;.nc.ascii?VVEL[0:1:0][0:1:0][0:1:719][0:1:1439]&amp;#034; &amp;amp; /@ (StringJoin[{ToString[#[[1]]], StringTake[StringJoin[ToString /@ PadLeft[{#[[2]]}, 2]], -2],StringTake[StringJoin[ToString /@ PadLeft[{#[[3]]}, 2]], -2]}] &amp;amp; /@ Table[Normal[DatePlus[DateObject[{1992, 1, 2}], 3*n]], {n, 0, 2556}]));&#xD;
&#xD;
These filenames cover a time interval from the beginning of 1992 to 2012. We then download the actual data (which can take really long):&#xD;
&#xD;
    Monitor[For[k = 1, k &amp;lt;= Length[filenamesV], k++, &#xD;
      Export[&amp;#034;~/Desktop/OceanVelocities/velV&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;, &#xD;
       ToExpression[StringSplit[StringSplit[#, &amp;#034;],&amp;#034;][[2]], &amp;#034;,&amp;#034;]] &amp;amp; /@ &#xD;
        StringSplit[Import[filenamesV[[k]]], &amp;#034;VVEL.VVEL[VVEL.TIME=&amp;#034;][[&#xD;
         2 ;;]] ]], &#xD;
     ProgressIndicator[Dynamic[k], {0, Length[filenamesV]}]]&#xD;
&#xD;
and&#xD;
&#xD;
    Monitor[For[k = 1, k &amp;lt;= Length[filenamesU], k++, &#xD;
      Export[&amp;#034;~/Desktop/OceanVelocities/velU&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;, &#xD;
       ToExpression[StringSplit[StringSplit[#, &amp;#034;],&amp;#034;][[2]], &amp;#034;,&amp;#034;]] &amp;amp; /@ &#xD;
        StringSplit[Import[filenamesU[[k]]], &amp;#034;UVEL.UVEL[UVEL.TIME=&amp;#034;][[&#xD;
         2 ;;]] ]], &#xD;
     ProgressIndicator[Dynamic[k], {0, Length[filenamesU]}]]&#xD;
&#xD;
This will download about 16GB worth of data. You will, however, get reasonable results if you only use 30 frames, i.e. if you substitute Length[filenamesU] and Length[filenamesV] by 30. We will now create a figure for the first frame.&#xD;
&#xD;
    velV1 = Import[&amp;#034;~/Desktop/OceanVelocities/velV1.csv&amp;#034;];&#xD;
    velU1 = Import[&amp;#034;~/Desktop/OceanVelocities/velU1.csv&amp;#034;];&#xD;
&#xD;
We can now generate the velocity vectors for each point on the surface of the earth&#xD;
&#xD;
    veltot = Table[{velU1[[i, j]], velV1[[i, j]]}, {i, 1, 720}, {j, 1, 1440}];&#xD;
&#xD;
and then clean the data&#xD;
&#xD;
    veltot2 = Table[If[((StringQ[#[[1]]] || StringQ[#[[2]]]) &amp;amp; /@ {veltot[[i, j]] })[[1]], {0., 0.}, {velU1[[i, j]], velV1[[i, j]]}], {i, 1, 720}, {j, 1, 1440}];&#xD;
&#xD;
We can also calculate the speed at each point.&#xD;
&#xD;
    veltottot = Table[If[((StringQ[#[[1]]] || StringQ[#[[2]]]) &amp;amp; /@ {veltot[[i, j]] })[[1]], 0., Norm[{velU1[[i, j]], velV1[[i, j]]}]], {i, 1, 720}, {j, 1, 1440}];&#xD;
&#xD;
This next function will produce a visualisation of the speed profile for the first frame.&#xD;
&#xD;
    Show[ArrayPlot[Reverse[veltottot], PlotLegends -&amp;gt; Automatic, ImageSize -&amp;gt; Full, ColorFunction -&amp;gt; &amp;#034;TemperatureMap&amp;#034;], ListVectorPlot[Transpose[veltot2], VectorPoints -&amp;gt; 50]]&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
Note the incredible fine-structure in that image. We could now produce an animation for all frames. This will, however, be too large for the memory of most computers, so I would not execute it. If you only use the first 30 frames you get a reasonable idea of its working.&#xD;
&#xD;
    framesflow = {}; Monitor[&#xD;
     For[k = 1, k &amp;lt;= Length[filenamesU], k++, &#xD;
      velU1 = Import[&amp;#034;~/Desktop/velU&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;]; &#xD;
      velV1 = Import[&amp;#034;~/Desktop/velV&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;];&#xD;
      veltot = Table[{velU1[[i, j]], velV1[[i, j]]}, {i, 1, 720}, {j, 1, 1440}]; &#xD;
      AppendTo[framesflow, ArrayPlot[Reverse[Table[If[((StringQ[#[[1]]] || StringQ[#[[2]]]) &amp;amp; /@ {veltot[[i,j]] })[[1]], 0., Norm[{velU1[[i, j]], velV1[[i, j]]}]], {i, 1, 720}, {j, 1, 1440}]], PlotLegends -&amp;gt; Automatic, ImageSize -&amp;gt; Full, ColorFunction -&amp;gt; &amp;#034;TemperatureMap&amp;#034;]]], k];&#xD;
&#xD;
This following command exports all the frames as individual gif files, which can later be combined into a gif animation. &#xD;
&#xD;
    Monitor[For[k = 1, k &amp;lt;= Length[filenamesU], k++, &#xD;
       velU1 = Import[&#xD;
         &amp;#034;~/Desktop/OceanVelocities/velU&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;]; &#xD;
       velV1 = Import[&#xD;
         &amp;#034;~/Desktop/OceanVelocities/velV&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;];&#xD;
       veltot = &#xD;
        Table[{velU1[[i, j]], velV1[[i, j]]}, {i, 1, 720}, {j, 1, 1440}]; &#xD;
       Export[&amp;#034;~/Desktop/MovieOut/frame&amp;#034; &amp;lt;&amp;gt; ToString[1000 + k] &amp;lt;&amp;gt; &amp;#034;.gif&amp;#034;, &#xD;
        ArrayPlot[Reverse[Table[If[((StringQ[#[[1]]] || StringQ[#[[2]]]) &amp;amp; /@ {veltot[[i,j]] })[[1]], 0., Norm[{velU1[[i, j]], velV1[[i, j]]}]], {i, 1, 720}, {j, 1, 1440}]], PlotLegends -&amp;gt; None, ImageSize -&amp;gt; {1440, 730}, ColorFunction -&amp;gt; &amp;#034;TemperatureMap&amp;#034;]]], k];&#xD;
&#xD;
Another advantage of saving the frames is that we can use them as background for various scenarios and thereby decrease our computation time substantially. Here is a short animation of the first couple of frames.&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
Now we get the trajectories of radioactive particles that are released into the ocean at the approximate site of the Fukushima power plant. We make the assumption that the particles simply follow the flow. Also, we use the vectorfield starting on 2nd January 1992. The overall patterns of the ocean currents seem to be reasonably stable over the years so that for this conceptual study this assumption will have to suffice. It is of course easy to adapt to the actual date. &#xD;
&#xD;
We first need to introduce a formula to convert the data grid to the surface of the earth. &#xD;
&#xD;
    ClearAll[&amp;#034;Global`*&amp;#034;];&#xD;
    f[teta_, r_, vx_, vy_] := {vx/(r*Sin[2*Pi*teta/4./360.]*2*Pi/360/4)*24*3600, vy/(N[r*2*Pi/360/4])*24*3600};&#xD;
    teta = 1; r = 6360000;&#xD;
&#xD;
We now place 20000 particle into the see close to the location of Fukushima. We add a small random number to the position to model a &amp;#034;cloud&amp;#034; of particles.&#xD;
&#xD;
    teilreinpos = &#xD;
     Table[{3, 511 + RandomVariate[NormalDistribution[0., 1.]], 568 + RandomVariate[NormalDistribution[0., 1.]]}, {m, 1, 20000}]; &#xD;
&#xD;
This is the main part of the program. We use the velocity to update the position of the particles. We then use the back-ground frames generated above and overlay the particle positions.&#xD;
&#xD;
    trajectories = {teilreinpos};&#xD;
    Monitor[Do[&#xD;
       velVt = Table[&#xD;
         If[StringQ[#], &#xD;
              0.1*(ToExpression[#[[&#xD;
                     3]]]*10^(ToExpression[#[[1]]]) ) &amp;amp; /@ { &#xD;
                StringSplit[#, {&amp;#034; &amp;#034;, &amp;#034;*&amp;#034;}]}, 1.*#] &amp;amp; /@ # &amp;amp; /@ &#xD;
          Import[&amp;#034;~/Desktop/OceanVelocities/velV&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &#xD;
            &amp;#034;.csv&amp;#034;, &amp;#034;CSV&amp;#034;], {k, i - 2, i + 2}];&#xD;
       velUt = &#xD;
        Table[If[StringQ[#], &#xD;
              0.1*(ToExpression[#[[&#xD;
                     3]]]*10^(ToExpression[#[[1]]]) ) &amp;amp; /@ { &#xD;
                StringSplit[#, {&amp;#034; &amp;#034;, &amp;#034;*&amp;#034;}]}, 1.*#] &amp;amp; /@ # &amp;amp; /@ &#xD;
          Import[&amp;#034;~/Desktop/OceanVelocities/velU&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &#xD;
            &amp;#034;.csv&amp;#034;, &amp;#034;CSV&amp;#034;], {k, i - 2, i + 2}];&#xD;
       xfunc = ListInterpolation[velUt, {{1, 5}, {0, 720}, {0, 1440}}];&#xD;
       yfunc = ListInterpolation[velVt, {{1, 5}, {0, 720}, {0, 1440}}];&#xD;
       AppendTo[trajectories, &#xD;
        Nest[({#[[1]], Mod[#[[2]], 720], &#xD;
               Mod[#[[3]], 1440]}) &amp;amp; /@ (# + {0.1, &#xD;
                0.1*f[#[[2]], r, xfunc[#[[1]] - i + 3., #[[2]], #[[3]]], &#xD;
                   yfunc[#[[1]] - i + 3., #[[2]], #[[3]]]][[2]] , &#xD;
                0.1*f[#[[2]], r, xfunc[#[[1]] - i + 3., #[[2]], #[[3]]], &#xD;
                   yfunc[#[[1]] - i + 3., #[[2]], #[[3]]]][[1]] } &amp;amp;) , # ,&#xD;
            10] &amp;amp; /@ trajectories[[-1]]]; &#xD;
       Export[&amp;#034;~/Desktop/OilSpillFrames/frame&amp;#034; &amp;lt;&amp;gt; ToString[1000 + i] &amp;lt;&amp;gt; &#xD;
         &amp;#034;.gif&amp;#034;, Show[&#xD;
         Import[&amp;#034;~/Desktop/MovieOut/frame&amp;#034; &amp;lt;&amp;gt; ToString[1000 + i] &amp;lt;&amp;gt; &#xD;
           &amp;#034;.gif&amp;#034;], &#xD;
         Graphics[{Red, Disk[#, 1]} &amp;amp; /@ (0.9361111 # + {44., 28.} &amp;amp; /@ &#xD;
             trajectories[[i - 2, All, {3, 2}]]), &#xD;
          PlotRange -&amp;gt; {{0, 1440}, {0, 720}}]]];&#xD;
       , {i, 3, 1238}], i];&#xD;
&#xD;
Here are a couple of frames:&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
All frames yield the following animation. &#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
Also see the higher quality animation on Youtube. [https://youtu.be/8icgMg6lt0Y][7]&#xD;
&#xD;
Similarly we can study where rubbish, such as plastic bags would accumulate in the oceans due to the currents; these are also called [gyres of marine debris particles][8]. See also [this link][9].&#xD;
&#xD;
We start out just like for the Fukushima simulation:&#xD;
&#xD;
    ClearAll[&amp;#034;Global`*&amp;#034;];&#xD;
    f[teta_, r_, vx_, vy_] := {vx/(r*Sin[2*Pi*teta/4./360.]*2*Pi/360/4)*24*3600, vy/(N[r*2*Pi/360/4])*24*3600};&#xD;
    teta = 1; r = 6360000;&#xD;
&#xD;
In this case we have to distribute the particles randomly in all oceans. So I will basically distribute them everywhere and then ingore the ones over land mass, by checking whether the background flow speed is zero. So we first calculate the speed.&#xD;
&#xD;
    velVt = Table[&#xD;
       If[StringQ[#], &#xD;
            0.1*(ToExpression[#[[3]]]*10^(ToExpression[#[[1]]]) ) &amp;amp; /@ { &#xD;
              StringSplit[#, {&amp;#034; &amp;#034;, &amp;#034;*&amp;#034;}]}, 1.*#] &amp;amp; /@ # &amp;amp; /@ &#xD;
        Import[&amp;#034;~/Desktop/OceanVelocities/velV&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;, &#xD;
         &amp;#034;CSV&amp;#034;], {k, 3 - 2, 3 + 2}];&#xD;
    velUt = Table[&#xD;
       If[StringQ[#], &#xD;
            0.1*(ToExpression[#[[3]]]*10^(ToExpression[#[[1]]]) ) &amp;amp; /@ { &#xD;
              StringSplit[#, {&amp;#034; &amp;#034;, &amp;#034;*&amp;#034;}]}, 1.*#] &amp;amp; /@ # &amp;amp; /@ &#xD;
        Import[&amp;#034;~/Desktop/OceanVelocities/velU&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;, &#xD;
         &amp;#034;CSV&amp;#034;], {k, 3 - 2, 3 + 2}];&#xD;
    &#xD;
    xfunc = ListInterpolation[velUt, {{1, 5}, {0, 720}, {0, 1440}}];&#xD;
    yfunc = ListInterpolation[velVt, {{1, 5}, {0, 720}, {0, 1440}}];&#xD;
&#xD;
We then distribute the particles everywhere&#xD;
&#xD;
    teilreinpospre = Table[{3, RandomReal[{0, 720}], RandomReal[{0, 1440}]}, {k, 1, 30000}];&#xD;
&#xD;
and delete the particles with zero-speed-background.&#xD;
&#xD;
    teilreinpos = Select[teilreinpospre, xfunc[3, #[[2]], #[[3]]] != 0. &amp;amp;&amp;amp; yfunc[3, #[[2]], #[[3]]] != 0. &amp;amp;];&#xD;
&#xD;
Now we iterate as before. &#xD;
&#xD;
    trajectories = {teilreinpos};&#xD;
    Monitor[Do[&#xD;
       velVt = Table[&#xD;
         If[StringQ[#], &#xD;
              0.1*(ToExpression[#[[&#xD;
                     3]]]*10^(ToExpression[#[[1]]]) ) &amp;amp; /@ { &#xD;
                StringSplit[#, {&amp;#034; &amp;#034;, &amp;#034;*&amp;#034;}]}, 1.*#] &amp;amp; /@ # &amp;amp; /@ &#xD;
          Import[&amp;#034;~/Desktop/OceanVelocities/velV&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &#xD;
            &amp;#034;.csv&amp;#034;, &amp;#034;CSV&amp;#034;], {k, i - 2, i + 2}];&#xD;
       velUt = &#xD;
        Table[If[StringQ[#], &#xD;
              0.1*(ToExpression[#[[&#xD;
                     3]]]*10^(ToExpression[#[[1]]]) ) &amp;amp; /@ { &#xD;
                StringSplit[#, {&amp;#034; &amp;#034;, &amp;#034;*&amp;#034;}]}, 1.*#] &amp;amp; /@ # &amp;amp; /@ &#xD;
          Import[&amp;#034;~/Desktop/OceanVelocities/velU&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &#xD;
            &amp;#034;.csv&amp;#034;, &amp;#034;CSV&amp;#034;], {k, i - 2, i + 2}];&#xD;
       xfunc = ListInterpolation[velUt, {{1, 5}, {0, 720}, {0, 1440}}];&#xD;
       yfunc = ListInterpolation[velVt, {{1, 5}, {0, 720}, {0, 1440}}];&#xD;
       AppendTo[trajectories, &#xD;
        Nest[({#[[1]], Mod[#[[2]], 720], &#xD;
               Mod[#[[3]], 1440]}) &amp;amp; /@ (# + {0.1, &#xD;
                RandomVariate[NormalDistribution[0., 0.05]] + &#xD;
                 0.1*f[#[[2]], r, xfunc[#[[1]] - i + 3., #[[2]], #[[3]]], &#xD;
                    yfunc[#[[1]] - i + 3., #[[2]], #[[3]]]][[2]] , &#xD;
                RandomVariate[NormalDistribution[0., 0.05]] + &#xD;
                 &#xD;
                 0.1*f[#[[2]], r, xfunc[#[[1]] - i + 3., #[[2]], #[[3]]], &#xD;
                    yfunc[#[[1]] - i + 3., #[[2]], #[[3]]]][[&#xD;
                   1]] } &amp;amp;) , # , 10] &amp;amp; /@ trajectories[[-1]]]; &#xD;
       Export[&amp;#034;~/Desktop/Rubbish/frame&amp;#034; &amp;lt;&amp;gt; ToString[1000 + i] &amp;lt;&amp;gt; &amp;#034;.gif&amp;#034;, &#xD;
        Show[Import[&#xD;
          &amp;#034;~/Desktop/MovieOut/frame&amp;#034; &amp;lt;&amp;gt; ToString[1000 + i] &amp;lt;&amp;gt; &amp;#034;.gif&amp;#034;], &#xD;
         Graphics[{Red, Disk[#, 1]} &amp;amp; /@ (0.9361111 # + {44., 28.} &amp;amp; /@ &#xD;
             trajectories[[i - 2, All, {3, 2}]]), &#xD;
          PlotRange -&amp;gt; {{0, 1440}, {0, 720}}]]];&#xD;
       , {i, 3, 1238}], i];&#xD;
&#xD;
Here are some frames:&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
This leads to the following animation (due to file size I only show a later part of the simulation).&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
Please have a look at the [higher resolution and longer animation on Youtube][11]. &#xD;
&#xD;
It becomes clear that there are 5 large areas of rubbish in the oceans. This and their approximate positions are in accordance with their known positions and satellite data. &#xD;
&#xD;
This type of simulation is very much simplified. We are making many assumptions, but by using the &amp;#034;observed&amp;#034; velocity field, we get around the fluid mechanical problems usually involved in these problems. The main idea can be used for many other problems as well. For example, we could iterate backwards to see where particles came from. &#xD;
&#xD;
So I challenge you to simulate the following. Several fragments of the crashed Malaysian airplane have been found. Can you use the flow, invert the time direction and simulate where the parts must have come from? I wonder whether you can make better assmumptions than me (the larger fragments drift differently in the currents), and whether your point of origin correponds to mine.&#xD;
&#xD;
I would love to hear back from you, and get ideas of how to apply this. I had a previous discussion with Vitaliy Kaurov about this, and there are certainly much nicer ways of representing the results. Any ideas are welcome.&#xD;
&#xD;
Cheers,  &#xD;
Marco&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Rubbish-final-optimize.gif&amp;amp;userId=20103&#xD;
  [2]: http://community.wolfram.com/web/bschelter&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2015-10-24at01.21.46.png&amp;amp;userId=48754&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=VelocityField.gif&amp;amp;userId=48754&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2015-10-24at01.28.35.png&amp;amp;userId=48754&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Fukushima-ok.gif&amp;amp;userId=48754&#xD;
  [7]: https://youtu.be/8icgMg6lt0Y&#xD;
  [8]: https://en.wikipedia.org/wiki/Great_Pacific_garbage_patch&#xD;
  [9]: https://en.wikipedia.org/wiki/File:Garbage_Patch_Visualization_Experiment.webm&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2015-10-24at01.36.47.png&amp;amp;userId=48754&#xD;
  [11]: https://youtu.be/ttJPAIBch8U</description>
    <dc:creator>Marco Thiel</dc:creator>
    <dc:date>2015-10-24T00:43:19Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/946991">
    <title>Brain mass versus body mass for mammals</title>
    <link>https://community.wolfram.com/groups/-/m/t/946991</link>
    <description>It&amp;#039;s quite amazing that humans can abstract patterns in nature and see similarities between, for example, pigmentation of some [mollusc shells and cellular automata][1]. The amazement deepens as we discover that [mathematical relations][2] and [simple programs][3] can grasp the essence of numerous patterns. Below is an example. A &amp;#034;line&amp;#034; is one of the simplest patterns in nature and is easily caught by human eye. So it is quite miraculous to see points with coordinates `(brain mass, body mass)` for various mammals would suddenly arrange along a straight line in log-log coordinate system. Which right away implies a power or scaling mathematical law that is very universal in nature. It is known as [Snell&amp;#039;s equation][4] in simple [allometry][5] due to Otto Snell (1891). It&amp;#039;s not to be confused with [Snell&amp;#039;s law][6] of optics due to Willebrord Snell (1621). Let&amp;#039;s see how we can build this wonderful plot.&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
I start from searching Wolfram Language built-in data resources for animal-related sets:&#xD;
&#xD;
    ResourceSearch[&amp;#034;animal&amp;#034;]&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
Let&amp;#039;s grab the first one:&#xD;
&#xD;
    data = ResourceData[&amp;#034;Animal Weights Sample Data&amp;#034;]&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
A simple plot of brain vs body mass does not reveal anything obvious:&#xD;
&#xD;
    ListPlot[Normal[data[All, {1000 #BodyWeight, #BrainWeight} &amp;amp;]], PlotTheme -&amp;gt; &amp;#034;Business&amp;#034;]&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
And by browsing the data we see we got a few long-dead species:&#xD;
&#xD;
    Interpreter[&amp;#034;Dinosaur&amp;#034;][{&amp;#034;Diplodocus&amp;#034;, &amp;#034;Triceratops&amp;#034;, &amp;#034;Brachiosaurus&amp;#034;}]&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
    EntityValue[%, &amp;#034;Image&amp;#034;]&#xD;
&#xD;
![enter image description here][12]&#xD;
&#xD;
Let&amp;#039;s delete these old friends and concentrate on modern species:&#xD;
&#xD;
    modern = Delete[data, {{6}, {16}, {26}}];&#xD;
&#xD;
and find equation of line passing through the log of data points:&#xD;
&#xD;
    f[x_] = Fit[Log[QuantityMagnitude[&#xD;
        Normal[modern[All, {1000 #BodyWeight, #BrainWeight} &amp;amp;]]]], {1, x},x]&#xD;
&#xD;
    Out[]= -3.04602 + 0.752261 x&#xD;
&#xD;
Getting it back into Snell&amp;#039;s equation power-from I get:&#xD;
&#xD;
    eq = Rationalize[BRAIN ? First[BRAIN /. &#xD;
         Solve[(f[x] /. x -&amp;gt; Log[BODY]) == Log[BRAIN], BRAIN]], .01]&#xD;
&#xD;
![enter image description here][13]&#xD;
&#xD;
And now to make the final plot above we use `ListLogLogPlot`:&#xD;
&#xD;
    Show[&#xD;
    	ListLogLogPlot[Normal[modern[All,Callout[{1000#BodyWeight,#BrainWeight},#Species]&amp;amp;]],&#xD;
    		PlotTheme-&amp;gt;&amp;#034;Detailed&amp;#034;,AspectRatio-&amp;gt;1],&#xD;
    		Plot[f[x],{x,3,16},PlotStyle-&amp;gt;Directive[Red,Dashed,Opacity[.8]]],&#xD;
    		BaseStyle-&amp;gt;13,&#xD;
    		PlotLabel-&amp;gt;Style[&amp;#034;brain vs body mass for mammals&amp;#034;,25,Darker[Red],FontFamily-&amp;gt;&amp;#034;Phosphate&amp;#034;],&#xD;
    		FrameLabel-&amp;gt;{&amp;#034;Body Weight, g&amp;#034;,&amp;#034;Brain Weight, g&amp;#034;},&#xD;
    		Epilog-&amp;gt;Inset[Style[eq,18,Red],Scaled[{.2,.8}]]&#xD;
    ]&#xD;
&#xD;
Of course, the mathematical formula is just an approximation and the constants change slightly for a different set of animals. For instance, [according to Harry J. Jerison][14] (UCLA):&#xD;
&#xD;
![enter image description here][15]&#xD;
&#xD;
## Further reading:&#xD;
- https://en.wikipedia.org/wiki/Brain%E2%80%93body_mass_ratio&#xD;
- https://en.wikipedia.org/wiki/Encephalization_quotient&#xD;
- https://doi.org/10.1093/jmammal/gyz043 &#xD;
&#xD;
&#xD;
  [1]: https://www.wolframscience.com/nksonline/page-423&#xD;
  [2]: https://en.wikipedia.org/wiki/The_Unreasonable_Effectiveness_of_Mathematics_in_the_Natural_Sciences&#xD;
  [3]: http://www.wolframscience.com/nksonline/page-363&#xD;
  [4]: https://en.wikipedia.org/wiki/Brain-to-body_mass_ratio&#xD;
  [5]: https://www.britannica.com/science/allometry&#xD;
  [6]: https://www.britannica.com/science/Snells-law&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2016-10-20at8.00.23PM.png&amp;amp;userId=11733&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2016-10-20at7.29.22PM.png&amp;amp;userId=11733&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=asdf435ytrhsgfda.png&amp;amp;userId=11733&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=sdf234q5yeuthrgsfds.png&amp;amp;userId=11733&#xD;
  [11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2016-10-20at7.37.48PM.png&amp;amp;userId=11733&#xD;
  [12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2016-10-20at7.38.57PM.png&amp;amp;userId=11733&#xD;
  [13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2016-10-20at7.44.26PM.png&amp;amp;userId=11733&#xD;
  [14]: http://brainmuseum.org/evolution/paleo/index.html&#xD;
  [15]: http://community.wolfram.com//c/portal/getImageAttachment?filename=BrnBodwt6.jpg&amp;amp;userId=11733</description>
    <dc:creator>Vitaliy Kaurov</dc:creator>
    <dc:date>2016-10-21T00:48:46Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/897811">
    <title>[WSS16] Quantum Computing with the Wolfram Language</title>
    <link>https://community.wolfram.com/groups/-/m/t/897811</link>
    <description>**Introduction to the Problem**&#xD;
&#xD;
While a gate-based quantum computer has yet to be implemented at the level of more than a handful of qubits, and some worry that the decoherence problem will remain an obstacle to real-world use of these machines; the field of theoretical quantum computing has its own virtue apart from these problems of construction and implementation. The theory of quantum computation and quantum algorithms have been used as powerful tools to tackle long-standing problems in classical computation such as proving the security of certain encryption schemes and refining complexity classifications for &#xD;
some approaches to the Traveling Salesman problem. Moreover, learning how to apply quantum effects like superposition, interference, and entanglement in a useful, computational, manner can help students gain a better understanding of how the quantum world really works. These educational and research advantages of quantum computing, along with the ever-present goal of designing new quantum algorithms that can provide us with speedups over their classical counterparts, furnish ample reason to make the field as accessible as possible. The goal of this project was to do just that by using the Wolfram language to design functionality that allows for researchers and students alike to engage with quantum computing in a meaningful way.&#xD;
&#xD;
**Getting it Done**&#xD;
&#xD;
This project involved the design and development of a suite of functions that allows for the simulation of quantum computing algorithms. The overarching goal was a framework that allows for easy implementation of quantum circuits, with minimal work done by the user. The specific design challenges were to have a tool simple enough to be used as an educational aide and powerful enough for researchers. To this end circuits can be built iteratively, allowing  students, and those new to quantum computing, to build a working knowledge of the field as they increase the complexity of the algorithms. The system has a universal set of gates allowing it to carry out any operation possible for a quantum computer (up to limits on the number of qubits due to the size of the register).&#xD;
&#xD;
&#xD;
----------&#xD;
&#xD;
&#xD;
*Short note on this: I have not rigorously tested the system yet, but unless you want to wait several hours for  your computation to complete, I             suggest not attempting computations with more than ~20 qubits. To classically simulate an N-qubit register, requires a state vector of length 2&amp;lt;sup&amp;gt;N&amp;lt;/sup&amp;gt;. Interestingly, it is this insight into the computational difficulty of simulating a quantum state that led Feynman to realize the power that quantum computing could have.*&#xD;
&#xD;
&#xD;
----------&#xD;
&#xD;
&#xD;
The project has functionality for the following gates: Hadamard, X, Y, Z, Rotation (any angle, about any axis), C-NOT, C-anything, SWAP, and QFT. It takes input in standard quantum circuit notation, and can output circuit diagrams, and the corresponding unitary transformation matrix as well as return the probabilities for results of measurements on a given qubit. Moreover, there is built in functionality for easy circuit addition, allowing one to stitch together large circuits from smaller ones, a boon for comprehension and testing.&#xD;
&#xD;
**A Simple Example**&#xD;
&#xD;
We initialize some random circuit by specifying it&amp;#039;s corresponding circuit notation. For sake of brevity, we start with a medium-sized circuit that is already formed, and perform operations on it, but one can easily build a circuit up qubit-by-qubit and gate-by-gate with the applyQ and circuitQ functions. Below we name some variable `quantumCircuit` using the function `circuitQ` to which we pass some circuit notation. This notation is just a matrix representing the quantum logic circuit, with the gates and qubits arranged schematically. &#xD;
&#xD;
    quantumCircuit= circuitQ[{{&amp;#034;H&amp;#034;, &amp;#034;R[1,Pi/2]&amp;#034;, &amp;#034;N&amp;#034;, &amp;#034;SWAP1&amp;#034;}, {&amp;#034;H&amp;#034;, 1, &amp;#034;C&amp;#034;, &#xD;
    &amp;#034;SWAP2&amp;#034;}, {&amp;#034;X&amp;#034;, 1, &amp;#034;C&amp;#034;, 1}}];&#xD;
&#xD;
`circuitQ` outputs the circuit diagram corresponding to the notation given:&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
But, say I wish to alter the circuit. We can add in as many layers of gates or extra qubits as we wish, without having to deal with the pesky notation matrix. Here I add a Hadamard gate to the second qubit after the SWAP using the function `applyQ`:&#xD;
&#xD;
    applyQ[quantumCircuit, &amp;#034;H&amp;#034;, 2]&#xD;
the output of which is:&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
One can also use `Append`, `Join`,`Nest` and a variety of other Wolfram language functions to build up highly complex circuits. However, the `circuitQ` function is overloaded, and one can also perform computations with it. We will now build the actual unitary transformation matrix that corresponds to the circuit diagram:&#xD;
&#xD;
    unitar=matrixBuild@quantumCircuit&#xD;
which, for our circuit, produces:&#xD;
&#xD;
![enter image description here][3].&#xD;
&#xD;
Now we can easily perform operations with circuit. Let&amp;#039;s specify some random 3 qubit initial state (in the computational basis):&#xD;
&#xD;
    initalState = {1, 0, 0, 1, 0, 0, 1, 0} // Normalize&#xD;
![enter image description here][4]&#xD;
&#xD;
We can pass this initial state to the circuit easily with:&#xD;
&#xD;
    premeasure=unitar.initialState&#xD;
&#xD;
which gives back the state of the quantum register (in this case our 3 qubits) after they have been operated on by the circuit, but pre-measurement:&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
We can now sample our state using the `projection` function. Here we will calculate the probability of getting state |0&amp;gt; when measuring qubit #3:&#xD;
&#xD;
    projection[2,0,premeasure]&#xD;
&#xD;
which, for our case, gives back a probability of 2/3.&#xD;
&#xD;
**Wrap Up**&#xD;
&#xD;
This was only a very simple example. Using `applyQ` and `circuitQ` one can build and modify highly complex quantum circuits easily. `matrixBuild` does all the math of calculating the corresponding unitary transformation matrix for you. All that is left is for the user to pass an initial state and see the output. A good learning technique is to start with a very simple circuit and initial state, and slowly build up in complexity, performing measurements at each step, to build an intuition and working knowledge of any given quantum circuit.&#xD;
&#xD;
An obvious next step for the project would be to add functionality that allows for the easy implementation of a general quantum oracle. I would also like to add more gates to the gate library, including: $\sqrt{SWAP}$, Tofolli, and QFT&amp;lt;sup&amp;gt;-1&amp;lt;/sup&amp;gt; which were left out due to lack of time and are trivial to implement. These tools would make it significantly easier for researchers to model any given quantum circuit.&#xD;
&#xD;
**Where is the NKS?**&#xD;
&#xD;
Finding quantum algorithms that perform useful tasks faster than their classical counterparts is an open area of research. However, it is often quite difficult to design these algorithms to take advantage of interference, as well as the structure in a given computational problem that may be useful to exploit. As such, there are only a small number of important quantum algorithms that are currently known. Hopefully this tool will allow for NKS-style search experiments for interesting behavior in quantum circuits. Similar searches have been carried out for classical circuits, and the tools I built will make it easy to generate vast sets of random quantum circuits that follow certain rules. What remains is to build useful analytic tools for combing the space.&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=circuit.jpeg&amp;amp;userId=896802&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=circuit2.jpeg&amp;amp;userId=896802&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=unitar.jpeg&amp;amp;userId=896802&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=3114initialstate.jpeg&amp;amp;userId=896802&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=finalstate.jpeg&amp;amp;userId=896802</description>
    <dc:creator>Aaron Tohuvavohu</dc:creator>
    <dc:date>2016-08-02T02:35:38Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/603607">
    <title>First forays into game design and agent reasoning about uncertainty</title>
    <link>https://community.wolfram.com/groups/-/m/t/603607</link>
    <description>Over the past year, I&amp;#039;ve found it increasingly more difficult to find video games that can keep me entertained. This has forced me to focus more on making my own. Making games was the main reason I got into programming as a teenager (and a popular reason for many, I believe), so it&amp;#039;s nice to return to it. For my first game last year, I wanted to make something interesting as quickly as possible. This led me to make a small puzzle game. I prototyped it in Mathematica, and now you can play the JavaScript version here ( [www.gatheredgame.com][1] ).&#xD;
&#xD;
That was a fun exercise, but moving forward, I wanted to create less abstract systems. I&amp;#039;m interested in small fictional worlds, emphasizing intricacy and responsiveness. This would enable player-driven stories, without having to hand-code every possible outcome and without limiting myself to the building and strategy genres. Perhaps things like Dwarf Fortress, but more accessible and varied.&#xD;
&#xD;
I decided a key to accomplishing this was to more closely tie together the creative writing and programming parts of my design process. I knew that the final result wouldn&amp;#039;t hold my attention long enough to be worth the effort if I took the industry approach to game design by starting from an existing genre or game and changing the setting or adding a new feature. Some independent games have been successful by starting from a novel interaction mechanic, and then exploring the language of puzzles that can be generated from that grammar. A prominent example is Portal. I think starting from random creative writing exercises is more fun, but in my initial attempts I had to throw away many details to reduce the results down to something I could start coding. That made the design process feel very inefficient. I want coding a game to feel like creative writing, and I want the output to be interesting from the first few lines until the final result.&#xD;
&#xD;
Ever since reading NKS, I&amp;#039;ve been struck by how interesting a random cellular automata browser can be given how little code is required to make one. For example, try enabling rules below until interesting behavior is produced (click the squares to the right of the arrows).&#xD;
&#xD;
    SeedRandom[1];&#xD;
    init = RandomInteger[1, 100]; rule = &#xD;
     Table[False, {2^5}]; Row@{Column@&#xD;
       Table[Row@{Row[&#xD;
           IntegerDigits[a - 1, 2, &#xD;
             5] /. {0 -&amp;gt; &#xD;
              Graphics[{White, EdgeForm[{Thin, Black}], Rectangle[]}, &#xD;
               ImageSize -&amp;gt; 10], &#xD;
             1 -&amp;gt; Graphics[{Black, EdgeForm[{Thin, Black}], Rectangle[]}, &#xD;
               ImageSize -&amp;gt; 10]}], &amp;#034;\[Rule]&amp;#034;, &#xD;
          With[{a = a}, &#xD;
           Dynamic@Graphics[&#xD;
             Button[If[&#xD;
               rule[[a]], {{Black, EdgeForm[{Thin, Black}], &#xD;
                 Rectangle[]}}, {{White, EdgeForm[{Thin, Black}], &#xD;
                 Rectangle[]}}], rule[[a]] = ! rule[[a]]], &#xD;
             ImageSize -&amp;gt; 10]]}, {a, 2^5}], Spacer@10, &#xD;
      Dynamic@ArrayPlot[&#xD;
        CellularAutomaton[{FromDigits[Reverse@Boole@rule, 2], 2, 2}, init,&#xD;
          150], ImageSize -&amp;gt; 350]}&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
So I decided the easiest way to try and take advantage of the fundamental phenomenon that complex behavior isn&amp;#039;t difficult to produce, while simultaneously focusing on concrete objects, was to experiment with association automata. With &amp;#034;association&amp;#034; referring to Wolfram&amp;#039;s key/value dictionaries.&#xD;
&#xD;
I like starting from random story ideas. I currently pull random story tropes from the TV Tropes idea generator to get started. Sometimes I mix in a few random Wikipedia articles.&#xD;
&#xD;
    randomStoryIdea[] := &#xD;
     DynamicModule[{elements = &#xD;
        Import[&amp;#034;http://tvtropes.org/pmwiki/storygen.php&amp;#034;, &amp;#034;Data&amp;#034;][[2, 2, &#xD;
         2]]}, Dynamic@&#xD;
       Grid[MapIndexed[{#[[1]], &#xD;
           Hyperlink[#[[2]], &#xD;
            &amp;#034;http://tvtropes.org/pmwiki/pmwiki.php/Main/&amp;#034; &amp;lt;&amp;gt; &#xD;
             StringReplace[#[[2]], Except@LetterCharacter -&amp;gt; &amp;#034;&amp;#034;]], &#xD;
           Button[&amp;#034;New&amp;#034;, &#xD;
            elements[[#2[[1]]]] = &#xD;
             Import[&amp;#034;http://tvtropes.org/pmwiki/storygen.php&amp;#034;, &amp;#034;Data&amp;#034;][[2,&#xD;
               2, 2, #2[[1]]]]]} &amp;amp;, elements], Alignment -&amp;gt; Left]]&#xD;
&#xD;
Here is a random seed I&amp;#039;m working with now:&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
Then I start to stitch some of the elements together in my head. An evil poacher at a lighthouse made me think of a fisherman, perhaps a criminal hiding in a lighthouse who is fishing to survive. Chain of harm and monster adventurers made me think that perhaps his fishing activities are damaging a community of marine life under the dock, and some crabs attempt to stop him. Now I&amp;#039;ll start defining some entities and properties. I start with the properties that I think someone would consider most interesting at the end of a game. Health and location of main characters, how many catches did the fisherman complete, what is the state of the crab town?&#xD;
&#xD;
    entities = &amp;lt;|&#xD;
      &amp;#034;fisherman&amp;#034; -&amp;gt; &amp;lt;|&amp;#034;health&amp;#034; -&amp;gt; &amp;#034;healthy&amp;#034;, &amp;#034;location&amp;#034; -&amp;gt; &amp;#034;dock&amp;#034;, &#xD;
        &amp;#034;catches&amp;#034; -&amp;gt; 0|&amp;gt;,&#xD;
      &amp;#034;hero crab&amp;#034; -&amp;gt; &amp;lt;|&amp;#034;health&amp;#034; -&amp;gt; &amp;#034;healthy&amp;#034;|&amp;gt;,&#xD;
      &amp;#034;assistant crab&amp;#034; -&amp;gt; &amp;lt;|&amp;#034;health&amp;#034; -&amp;gt; &amp;#034;healthy&amp;#034;|&amp;gt;,&#xD;
      &amp;#034;crab town&amp;#034; -&amp;gt; &amp;lt;|&amp;#034;population&amp;#034; -&amp;gt; 50, &amp;#034;crime rate&amp;#034; -&amp;gt; .05|&amp;gt;&#xD;
      |&amp;gt;&#xD;
&#xD;
Then I define some rules to update those properties, referring to new properties that will influence them. In this way I essentially define the game world by starting from final effects and working backward by defining causes. The entities and properties are defined as an association of associations. The rules are defined as a list of lists that is then converted to associations with some code. Each sublist represents one rule that updates one property of one entity. The first two items of the sublist are the entity and property being updated, and the last item is a pure function that defines the behavior of the rule. Three values are passed to the rule when it is used. Slot[1] is the current value of the property being updated. Slot[2] is the current entity being updated, so I can refer to other properties of that entity easily with #2[&amp;#034;property&amp;#034;]. Slot[3] is the association containing the current state of all entities, so I can refer to properties of the fishing rod within a rule that updates the fisherman&amp;#039;s catch count with #3[&amp;#034;fishing rod&amp;#034;,&amp;#034;fish on line&amp;#034;].&#xD;
&#xD;
    rules = {&#xD;
      {&amp;#034;fisherman&amp;#034;, &amp;#034;health&amp;#034;, Which[&#xD;
         #2@&amp;#034;pacemaker&amp;#034; === &amp;#034;off&amp;#034;, &amp;#034;dead&amp;#034;,&#xD;
         #2@&amp;#034;fear level&amp;#034; &amp;gt;= 30, &amp;#034;dead&amp;#034;,&#xD;
         #2@&amp;#034;location&amp;#034; === &amp;#034;ocean&amp;#034;, &amp;#034;dead&amp;#034;,&#xD;
         #2@&amp;#034;blood level&amp;#034; &amp;lt; 30 &amp;amp;&amp;amp; # === &amp;#034;healthy&amp;#034;, &amp;#034;injured&amp;#034;,&#xD;
         #2@&amp;#034;blood level&amp;#034; &amp;lt;= 0, &amp;#034;dead&amp;#034;,&#xD;
         #2@&amp;#034;hunger level&amp;#034; &amp;gt;= 50, &amp;#034;dead&amp;#034;,&#xD;
         # === &amp;#034;injured&amp;#034; &amp;amp;&amp;amp; #2@&amp;#034;time without bleeding&amp;#034; &amp;gt;= 20, &amp;#034;healthy&amp;#034;,&#xD;
         True, #] &amp;amp;},&#xD;
      {&amp;#034;crab town&amp;#034;, &#xD;
       &amp;#034;population&amp;#034;, # + If[RandomReal[] &amp;lt; #2@&amp;#034;crime rate&amp;#034;, -1, 0] + &#xD;
         If[RandomReal[] &amp;lt; #/4*.005, 1, 0] &amp;amp;}&#xD;
      }&#xD;
&#xD;
Before we look at the behavior of the system, we need to define initial values for any new properties we reference in the rules. Here is some code to find those.&#xD;
&#xD;
    extractVars[fun_, scopedEntity_] := &#xD;
     Join[Cases[fun, #2[prop_] :&amp;gt; {scopedEntity, prop}, \[Infinity]], &#xD;
      Cases[fun, #3[globalEntity_, prop_] :&amp;gt; {globalEntity, &#xD;
         prop}, \[Infinity]], &#xD;
      Cases[fun, &#xD;
       prop[globalEntity_String, prop_String] :&amp;gt; {globalEntity, &#xD;
         prop}, \[Infinity]]]&#xD;
    &#xD;
    Complement[&#xD;
     Union[Join @@ (Prepend[extractVars[#3, #], {#, #2}] &amp;amp; @@@ rules)], &#xD;
     Join @@ KeyValueMap[Thread[{#, Keys@#2}] &amp;amp;, entities]]&#xD;
&#xD;
The following code expands the rules into associations and allows for simple one-level, OO-style inheritance of properties and rules by using an &amp;#034;is a&amp;#034; property on an entity. This example doesn&amp;#039;t utilize that, but the code to apply rules assumes they have been transformed into associations.&#xD;
&#xD;
    (*currently only supports one level of inheritance. inherited rules \&#xD;
    lose ordering*)&#xD;
    fullEntities = entities;&#xD;
    Select[fullEntities, KeyExistsQ@&amp;#034;is a&amp;#034;] // &#xD;
       KeyValueMap[{#, #2@&amp;#034;is a&amp;#034;} &amp;amp;] // &#xD;
      Apply[{entity, parent} \[Function] &#xD;
         AssociateTo[fullEntities, &#xD;
          entity -&amp;gt; &#xD;
           Join[fullEntities@parent, fullEntities@entity]], #, {1}] &amp;amp;;&#xD;
    &#xD;
    fullRules = &#xD;
      Select[entities, KeyExistsQ@&amp;#034;is a&amp;#034;] // &#xD;
        KeyValueMap[Cases[rules, {#2@&amp;#034;is a&amp;#034;, a__} :&amp;gt; {#, a}] &amp;amp;] // &#xD;
       Select[&amp;lt;|&amp;#034;entity&amp;#034; -&amp;gt; #, &amp;#034;property&amp;#034; -&amp;gt; #2, &amp;#034;rule&amp;#034; -&amp;gt; #3, &#xD;
            If[Length@{##} &amp;gt; 3, &amp;#034;probabilities&amp;#034; -&amp;gt; {##}[[4]], &#xD;
             &amp;#034;probabilities&amp;#034; -&amp;gt; Null]|&amp;gt;, # =!= Null &amp;amp;] &amp;amp; @@@ &#xD;
         Join[Catenate@#, rules] &amp;amp;;&#xD;
&#xD;
Then to step through the evolution of the system, we can use code like the following. In my example the only changes come from a gradually changing population due to birth and crime, so you can use the input field above the step button to take more than one step at a time:&#xD;
&#xD;
    applyRules[entities_, rules_] := &#xD;
     Fold[ReplacePart[#, {#2@&amp;#034;entity&amp;#034;, #2@&amp;#034;property&amp;#034;} -&amp;gt; #2[&#xD;
           &amp;#034;rule&amp;#034;][#[#2@&amp;#034;entity&amp;#034;, #2@&amp;#034;property&amp;#034;], #[#2@&amp;#034;entity&amp;#034;], #]] &amp;amp;, &#xD;
      entities, rules]&#xD;
    &#xD;
    play[] := (state = fullEntities; steps = 0; stepSize = 1; &#xD;
      Grid[{{Column@{InputField[Dynamic@stepSize, Number, FieldSize -&amp;gt; 4],&#xD;
            Button[&amp;#034;Step&amp;#034;, &#xD;
            state = Nest[applyRules[#, fullRules] &amp;amp;, state, stepSize]; &#xD;
            steps += stepSize], Dynamic@steps}, &#xD;
         Dynamic@Column@Normal[state]}}, Frame -&amp;gt; All, &#xD;
       Alignment -&amp;gt; {Center, Center}])&#xD;
    &#xD;
    play[]&#xD;
&#xD;
To help decide what rules to add next, I have some code that visualizes which properties influence other properties as a graph, and some code that sorts properties by how many other properties they influence. This makes it easy to add rules that have the greatest downstream effects on the system.&#xD;
&#xD;
    Graph[Flatten[&#xD;
      Thread[Union@extractVars[#[[3]], #[[1]]] \[DirectedEdge] #[[;; 2]], &#xD;
         List, 1] &amp;amp; /@ rules, 1], VertexLabels -&amp;gt; &amp;#034;Name&amp;#034;, &#xD;
     PlotRangePadding -&amp;gt; 1]&#xD;
    &#xD;
    Module[{counts = &#xD;
       Counts[Join @@ (Union@extractVars[#3, #] &amp;amp; @@@ fullRules)], &#xD;
      counts2 = Counts[Join @@ (extractVars[#3, #] &amp;amp; @@@ fullRules)]}, &#xD;
     Complement[&#xD;
        Join[Join @@ KeyValueMap[Thread[{#, Keys@#2}] &amp;amp;, fullEntities], &#xD;
         Keys@counts], Values@fullRules[[All, {&amp;#034;entity&amp;#034;, &amp;#034;property&amp;#034;}]]] //&#xD;
        Map[{#, Lookup[counts, Key@#, 0], Lookup[counts2, Key@#, 0]} &amp;amp;] //&#xD;
       SortBy[-Last@# &amp;amp;]]&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
As you start expanding your system, you&amp;#039;ll very quickly realize that defining rules for the behavior of &amp;#034;intelligent&amp;#034; entities in your system is very tedious. I&amp;#039;ve started investigating some ways to simplify this. We&amp;#039;ll use the fisherman as an example, but I plan to use the same techniques for the crabs and others. We can just treat his choice of what action to perform as a search and optimization problem. By giving him a utility or objective property to maximize like &amp;#034;happiness&amp;#034;, we can just have him search through a few steps of simulating the system for various possible actions and choose the one that leads to the most happiness.&#xD;
&#xD;
    optimize[property_, choices_, objective_, entities_, rules_, &#xD;
      searchDepth_] := &#xD;
     Module[{rulesSafe = &#xD;
        Select[rules, property =!= prop[#entity, #property] &amp;amp;]}, &#xD;
      First@MaximalBy[&#xD;
        Table[{c, &#xD;
          Module[{newState = &#xD;
             applyRules[ReplacePart[entities, List @@ property -&amp;gt; c], &#xD;
              rulesSafe]}, &#xD;
           If[searchDepth &amp;gt; 1, &#xD;
            Last@optimize[property, choices, objective, newState, &#xD;
              rulesSafe, searchDepth - 1], newState @@ objective]]}, {c, &#xD;
          entities @@ choices}], Last]]&#xD;
&#xD;
You would use that function similar to the following:&#xD;
&#xD;
    {&amp;#034;fisherman&amp;#034;, &amp;#034;action&amp;#034;, &#xD;
     First@optimize[prop[&amp;#034;fisherman&amp;#034;, &amp;#034;action&amp;#034;], &#xD;
        prop[&amp;#034;fisherman&amp;#034;, &amp;#034;possible actions&amp;#034;], &#xD;
        prop[&amp;#034;fisherman&amp;#034;, &amp;#034;happiness&amp;#034;], #3, fullRules, 5] &amp;amp;}&#xD;
&#xD;
I gave the fisherman a few possible actions (sitting, standing, casting, fishing, reeling, unhooking) and defined which ones are accessible under which conditions with nested Which expressions. Then I defined his happiness to increase by one whenever he unhooks a fish.&#xD;
&#xD;
Now we immediately run into a problem where he has no way to prioritize unhooking a fish now when he could just wait a turn and unhook it then. If he is recursively searching two moves ahead, then both unhooking now then waiting or waiting now then unhooking both return the same happiness. So depending on search order, he might just choose to wait every single step. One simple fix for this example is to just multiply his happiness by something like 1.01 at each step. Then he will prioritize unhooking the fish as soon as possible, because ((x+1)*1.01)*1.01 is greater than ((1.01*x)+1)*1.01. The sooner he gets happiness increases, the greater the effect of the ongoing multiplier. You could also have his happiness be diminished based on search depth in the optimization recursion, have the formula directly incorporate the amount of time that has passed in the game, etc.&#xD;
&#xD;
    entities = &amp;lt;|&#xD;
       &amp;#034;fisherman&amp;#034; -&amp;gt; &amp;lt;|&amp;#034;health&amp;#034; -&amp;gt; &amp;#034;healthy&amp;#034;, &amp;#034;location&amp;#034; -&amp;gt; &amp;#034;dock&amp;#034;, &#xD;
         &amp;#034;catches&amp;#034; -&amp;gt; 0, &amp;#034;action&amp;#034; -&amp;gt; &amp;#034;sitting&amp;#034;, &amp;#034;happiness&amp;#034; -&amp;gt; 50, &#xD;
         &amp;#034;possible actions&amp;#034; -&amp;gt; {&amp;#034;sitting&amp;#034;, &amp;#034;casting&amp;#034;, &amp;#034;standing&amp;#034;}, &#xD;
         &amp;#034;blood level&amp;#034; -&amp;gt; 100, &amp;#034;fear level&amp;#034; -&amp;gt; 0, &amp;#034;hunger level&amp;#034; -&amp;gt; 0, &#xD;
         &amp;#034;pacemaker&amp;#034; -&amp;gt; &amp;#034;on&amp;#034;, &amp;#034;time without bleeding&amp;#034; -&amp;gt; 0, &#xD;
         &amp;#034;catching fish&amp;#034; -&amp;gt; False|&amp;gt;,&#xD;
       &amp;#034;hero crab&amp;#034; -&amp;gt; &amp;lt;|&amp;#034;health&amp;#034; -&amp;gt; &amp;#034;healthy&amp;#034;|&amp;gt;,&#xD;
       &amp;#034;assistant crab&amp;#034; -&amp;gt; &amp;lt;|&amp;#034;health&amp;#034; -&amp;gt; &amp;#034;healthy&amp;#034;|&amp;gt;,&#xD;
       &amp;#034;crab town&amp;#034; -&amp;gt; &amp;lt;|&amp;#034;population&amp;#034; -&amp;gt; 50, &amp;#034;crime rate&amp;#034; -&amp;gt; .05|&amp;gt;,&#xD;
       &amp;#034;fishing rod&amp;#034; -&amp;gt; &amp;lt;|&amp;#034;crab on line&amp;#034; -&amp;gt; False|&amp;gt;,&#xD;
       &amp;#034;dock&amp;#034; -&amp;gt; &amp;lt;|&amp;#034;trip wire&amp;#034; -&amp;gt; &amp;#034;not set&amp;#034;|&amp;gt;&#xD;
       |&amp;gt;;&#xD;
    &#xD;
    rules = {&#xD;
       {&amp;#034;fisherman&amp;#034;, &amp;#034;action&amp;#034;, &#xD;
        First@optimize[prop[&amp;#034;fisherman&amp;#034;, &amp;#034;action&amp;#034;], &#xD;
           prop[&amp;#034;fisherman&amp;#034;, &amp;#034;possible actions&amp;#034;], &#xD;
           prop[&amp;#034;fisherman&amp;#034;, &amp;#034;happiness&amp;#034;], #3, fullRules, 5] &amp;amp;},&#xD;
       {&amp;#034;fisherman&amp;#034;, &#xD;
        &amp;#034;catching fish&amp;#034;, #2@&amp;#034;action&amp;#034; === &amp;#034;unhooking&amp;#034; &amp;amp;&amp;amp; #3[&amp;#034;fishing rod&amp;#034;, &#xD;
           &amp;#034;crab on line&amp;#034;] &amp;amp;},&#xD;
       {&amp;#034;crab town&amp;#034;, &amp;#034;crime rate&amp;#034;, .05 + .05*#3[&amp;#034;fisherman&amp;#034;, &amp;#034;catches&amp;#034;] &amp;amp;},&#xD;
       {&amp;#034;fisherman&amp;#034;, &amp;#034;location&amp;#034;, Which[&#xD;
          #2@&amp;#034;fear level&amp;#034; &amp;gt;= 20 &amp;amp;&amp;amp; # === &#xD;
            &amp;#034;dock&amp;#034; &amp;amp;&amp;amp; #3[&amp;#034;dock&amp;#034;, &amp;#034;trip wire&amp;#034;] === &amp;#034;set&amp;#034;, &amp;#034;ocean&amp;#034;,&#xD;
          #2@&amp;#034;action&amp;#034; === &amp;#034;going to lighthouse&amp;#034;, &amp;#034;lighthouse&amp;#034;,&#xD;
          #2@&amp;#034;action&amp;#034; === &amp;#034;going to dock&amp;#034;, &amp;#034;dock&amp;#034;,&#xD;
          True, #] &amp;amp;},&#xD;
       {&amp;#034;fisherman&amp;#034;, &amp;#034;possible actions&amp;#034;, Which[&#xD;
          #2@&amp;#034;location&amp;#034; === &amp;#034;dock&amp;#034;, Which[&#xD;
           #2@&amp;#034;action&amp;#034; === &amp;#034;sitting&amp;#034;, {&amp;#034;sitting&amp;#034;, &amp;#034;casting&amp;#034;, &amp;#034;standing&amp;#034;},&#xD;
           #2@&amp;#034;action&amp;#034; === &amp;#034;casting&amp;#034;, {&amp;#034;fishing&amp;#034;},&#xD;
           #2@&amp;#034;action&amp;#034; === &amp;#034;fishing&amp;#034;, {&amp;#034;fishing&amp;#034;, &amp;#034;reeling&amp;#034;},&#xD;
           #2@&amp;#034;action&amp;#034; === &amp;#034;reeling&amp;#034;, {&amp;#034;sitting&amp;#034;, &amp;#034;unhooking&amp;#034;},&#xD;
           #2@&amp;#034;action&amp;#034; === &amp;#034;unhooking&amp;#034;, {&amp;#034;sitting&amp;#034;},&#xD;
           #2@&amp;#034;action&amp;#034; === &amp;#034;standing&amp;#034;, {&amp;#034;sitting&amp;#034;, &amp;#034;going to lighthouse&amp;#034;},&#xD;
           True, #],&#xD;
          True, #] &amp;amp;},&#xD;
       {&amp;#034;fisherman&amp;#034;, &amp;#034;health&amp;#034;, Which[&#xD;
          #2@&amp;#034;pacemaker&amp;#034; === &amp;#034;off&amp;#034;, &amp;#034;dead&amp;#034;,&#xD;
          #2@&amp;#034;fear level&amp;#034; &amp;gt;= 30, &amp;#034;dead&amp;#034;,&#xD;
          #2@&amp;#034;location&amp;#034; === &amp;#034;ocean&amp;#034;, &amp;#034;dead&amp;#034;,&#xD;
          #2@&amp;#034;blood level&amp;#034; &amp;lt; 30 &amp;amp;&amp;amp; # === &amp;#034;healthy&amp;#034;, &amp;#034;injured&amp;#034;,&#xD;
          #2@&amp;#034;blood level&amp;#034; &amp;lt;= 0, &amp;#034;dead&amp;#034;,&#xD;
          #2@&amp;#034;hunger level&amp;#034; &amp;gt;= 50, &amp;#034;dead&amp;#034;,&#xD;
          # === &amp;#034;injured&amp;#034; &amp;amp;&amp;amp; #2@&amp;#034;time without bleeding&amp;#034; &amp;gt;= 20, &amp;#034;healthy&amp;#034;,&#xD;
          True, #] &amp;amp;},&#xD;
       {&amp;#034;fisherman&amp;#034;, &amp;#034;happiness&amp;#034;, &#xD;
        1.01 (# + If[#2@&amp;#034;catching fish&amp;#034;, 1, 0] - &#xD;
            If[#2@&amp;#034;health&amp;#034; === &amp;#034;injured&amp;#034;, 20, 0]) &amp;amp;},&#xD;
       {&amp;#034;fisherman&amp;#034;, &amp;#034;catches&amp;#034;, If[#2@&amp;#034;catching fish&amp;#034;, # + 1, #] &amp;amp;},&#xD;
       {&amp;#034;fishing rod&amp;#034;, &amp;#034;crab on line&amp;#034;, Which[&#xD;
          #3[&amp;#034;fisherman&amp;#034;, &amp;#034;action&amp;#034;] === &amp;#034;fishing&amp;#034; &amp;amp;&amp;amp; RandomReal[] &amp;lt; .1, &#xD;
          True,&#xD;
          #3[&amp;#034;fisherman&amp;#034;, &amp;#034;action&amp;#034;] === &amp;#034;unhooking&amp;#034;, False,&#xD;
          True, #] &amp;amp;},&#xD;
       {&amp;#034;crab town&amp;#034;, &#xD;
        &amp;#034;population&amp;#034;, # + If[RandomReal[] &amp;lt; #2@&amp;#034;crime rate&amp;#034;, -1, 0] + &#xD;
          If[RandomReal[] &amp;lt; #/4*.005, 1, 0] &amp;amp;}&#xD;
       };&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
So now if he was guaranteed to catch a fish within the search depth of his optimization (I&amp;#039;m using 5 for now), he would behave as desired. The problem is that for each step that he is fishing, he only has a 10% chance of a fish biting. This means that almost 9 of 10 times, his optimization search will return no better options than doing nothing. He needs to understand that the chance of catching a fish is always better than doing nothing. I&amp;#039;m experimenting with just manually annotating any rules that depend on randomness. Then I define a new optimization search function that can read these annotations, split the search into multiple branches when necessary, and return the expected happiness from the split. In our example, when he is fishing and no fish has bitten yet, it will return a happiness of .1*(the happiness from continuing the search assuming a fish bites)+.9*(the happiness from continuing the search assuming a fish doesn&amp;#039;t bite).&#xD;
&#xD;
    {&amp;#034;fishing rod&amp;#034;, &amp;#034;crab on line&amp;#034;, &#xD;
     Which[#3[&amp;#034;fisherman&amp;#034;, &amp;#034;action&amp;#034;] === &amp;#034;fishing&amp;#034; &amp;amp;&amp;amp; RandomReal[] &amp;lt; .1, &#xD;
       True, #3[&amp;#034;fisherman&amp;#034;, &amp;#034;action&amp;#034;] === &amp;#034;unhooking&amp;#034;, False, &#xD;
       True, #] &amp;amp;, {{#3[&amp;#034;fisherman&amp;#034;, &amp;#034;action&amp;#034;] === &#xD;
          &amp;#034;fishing&amp;#034; &amp;amp;&amp;amp; ! # &amp;amp;, {{.1, True}, {.9, False}}}}}&#xD;
    &#xD;
    relevantProbs[rule_, state_] := &#xD;
     If[KeyExistsQ[rule, &amp;#034;probabilities&amp;#034;], &#xD;
      Select[rule[&#xD;
        &amp;#034;probabilities&amp;#034;], #[[1]][state[rule@&amp;#034;entity&amp;#034;, rule@&amp;#034;property&amp;#034;], &#xD;
         state[rule@&amp;#034;entity&amp;#034;], state] &amp;amp;], {}]&#xD;
    &#xD;
    applyRulesProb[entities_, rules_] := &#xD;
     Fold[Function[{states, rule}, &#xD;
       Function[state, &#xD;
         If[Length@relevantProbs[rule, state[[2]]] &amp;gt; 0, &#xD;
          relevantProbs[rule, state[[2]]][[1, 2]] // &#xD;
            Map[Function[&#xD;
              branch, {branch[[1]]*state[[1]], &#xD;
               ReplacePart[&#xD;
                state[[2]], {rule@&amp;#034;entity&amp;#034;, rule@&amp;#034;property&amp;#034;} -&amp;gt; &#xD;
                 branch[[2]]]}]] // Sequence @@ # &amp;amp;, {state[[1]], &#xD;
           ReplacePart[&#xD;
            state[[2]], {rule@&amp;#034;entity&amp;#034;, rule@&amp;#034;property&amp;#034;} -&amp;gt; &#xD;
             rule[&amp;#034;rule&amp;#034;][state[[2]][rule@&amp;#034;entity&amp;#034;, rule@&amp;#034;property&amp;#034;], &#xD;
              state[[2]][rule@&amp;#034;entity&amp;#034;], state[[2]]]]}]] /@ states], {{1.,&#xD;
         entities}}, rules]&#xD;
    &#xD;
    optimizeProb[property_, choices_, objective_, entities_, rules_, &#xD;
      searchDepth_] := &#xD;
     Module[{rulesSafe = &#xD;
        Select[rules, property =!= prop[#entity, #property] &amp;amp;]}, &#xD;
      First@MaximalBy[&#xD;
        Table[{c, &#xD;
          Module[{newState = &#xD;
             applyRulesProb[ReplacePart[entities, List @@ property -&amp;gt; c], &#xD;
              rulesSafe]}, &#xD;
           If[searchDepth &amp;gt; 1, &#xD;
            Function[branch, &#xD;
               branch[[1]]*&#xD;
                Last@optimizeProb[property, choices, objective, &#xD;
                  branch[[2]], rulesSafe, searchDepth - 1]] /@ newState //&#xD;
              Total, Function[branch, &#xD;
               branch[[1]]*branch[[2]] @@ objective] /@ newState // &#xD;
             Total]]}, {c, entities @@ choices}], Last]]&#xD;
&#xD;
He now displays the desired behavior of choosing to start fishing immediately, waiting until a fish bites, then reeling and unhooking, then continuing.&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
Right now, the fisherman has perfect knowledge of the system. This is because I pass in the full rules and full set of entities of the system to the optimization search. An interesting next step as I add rules and properties to the system will be to use a subset of the entities and rules that represent his limited mind and knowledge. Then I can add rules that update his knowledge and even his happiness function over time to make him learn. For example, say whether or not a fish bites is actually deterministic based on more detailed rules for crab behavior. However, let&amp;#039;s says the fisherman&amp;#039;s copy of the system rules excludes those and instead just assumes a 30% random chance of catching a fish. Further, assume the 30% expectation is represented as a property of the fisherman (say &amp;#034;fishing optimism&amp;#034;). Then we can easily add a rule that increases his optimism whenever he catches a fish, and decreases it whenever he doesn&amp;#039;t. Then say we add time of day to the system, and expand his happiness function to decrease when he stays out too late fishing. Then he will automatically choose to stay out a little later when he has been a catching a lot of fish compared to when he hasn&amp;#039;t been catching many.&#xD;
&#xD;
That&amp;#039;s just one possible extension I&amp;#039;ve considered. I don&amp;#039;t know if this approach will ever lead to me making a commercially successful game, but it&amp;#039;s holding my attention for now.&#xD;
&#xD;
&#xD;
  [1]: http://www.gatheredgame.com/&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=sdfae54w6ujtyehrgeafsd.gif&amp;amp;userId=11733&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=7103temp.png&amp;amp;userId=64737&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=2015-11-02_11-02-21.png&amp;amp;userId=11733&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=5320temp.png&amp;amp;userId=64737&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=9395temp.gif&amp;amp;userId=64737</description>
    <dc:creator>Michael Hale</dc:creator>
    <dc:date>2015-11-01T23:48:50Z</dc:date>
  </item>
</rdf:RDF>

