<?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 Units sorted by most viewed.</description>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/344241" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/203498" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/293403" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/553861" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/775253" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/844216" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/745753" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1747298" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1899870" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1862464" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2134507" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1260622" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/3389913" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/133220" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/292343" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/430038" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1135312" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/984688" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1731427" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1046869" />
      </rdf:Seq>
    </items>
  </channel>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/344241">
    <title>Reading high resolution weather data from Netatmo</title>
    <link>https://community.wolfram.com/groups/-/m/t/344241</link>
    <description>Together with [Björn Schelter][1] I have tried to read in data from the personal weather station [Netatmo][2] &#xD;
&#xD;
![Reading high resolution weather data from Netatmo][3]&#xD;
&#xD;
which, as it turns out, is a very good companion for Mathematica; it also features in the [connected devices list of Wolfram][4].This device measures temperature, humidity, pressure, noise level and potentially the precipitation indoors and outdoors. Users are encouraged to share the outdoors data; as the weather station is rather popular there are lots of measurements. On their website [https://www.netatmo.com/][5] the company makes these measurements available. You can represent worldwide data &#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
(I know that that figure does not show the entire world!) or zoom in to street level data:&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
On the website [https://dev.netatmo.com][8] you can sign up for a developer account which gives you access to the API of netatmo. In this post I am going to show how to access the data with Mathematica. When you sign up for a netatmo developer account you will be issued a client id and a client secret. These are rather long strings. You will also get a username and a password for your account. Next you need to request an access token, which you can do via the following command:&#xD;
&#xD;
&amp;gt; curl -X POST -d &#xD;
&amp;gt; &amp;#034;grant_type=password&amp;amp;client_id=AAAAAAAAAAAAAAAAAAAA&amp;amp;client_secret=BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB&#xD;
&amp;gt; &amp;amp;username=XXXXXXXXXXXXXXXX&amp;amp;password=YYYYYYYYYYYYYYY&amp;amp;scope=read_station&amp;#034;&#xD;
&amp;gt; http://api.netatmo.net/oauth2/token&amp;gt; ~/Desktop/request-token.txt&#xD;
&#xD;
On a Mac I generate a file called netatmo.sh containing that string on the desktop; I obviously substitute AAAAAAAAAAAA by the client id, BBBBBBBBBBBBBBBB by the client secret, XXXXXXXXXXXX and YYYYYYYYYY by the user name and the password. Then I use the terminal command &#xD;
&#xD;
&amp;gt; chmod a+x netatmo.sh&#xD;
&#xD;
The rest is child&amp;#039;s play. We need to execute the command &#xD;
&#xD;
    Run[&amp;#034;~/Desktop/netatmo.sh&amp;#034;];&#xD;
    data = Import[&amp;#034;https://api.netatmo.net/api/getpublicdata?access_token=&amp;#034;&amp;lt;&amp;gt;Last[StringSplit[Import[&amp;#034;~/Desktop/request-token.txt&amp;#034;, &amp;#034;CSV&amp;#034;][[1, 1]], &amp;#034;\&amp;#034;&amp;#034;]] &amp;lt;&amp;gt; &#xD;
        &amp;#034;&amp;amp;lat_ne=59.91&amp;amp;lon_ne=13.75&amp;amp;lat_sw=40.42&amp;amp;lon_sw=-20.0&amp;amp;filter=True&amp;#034;, &amp;#034;Text&amp;#034;];&#xD;
&#xD;
Note that the numbers following lat_ne, lon_ne, lat_sw, lon_sw are the north east and south west latitudes and longitudes. If we want to request data for other regions we can do so by changing these entries. Next we clean the data a little bit:&#xD;
&#xD;
    tab = Quiet[&#xD;
    Select[Select[Table[ToExpression /@ Flatten[StringSplit[#, &amp;#034;]&amp;#034;] &amp;amp; /@ StringSplit[#, &amp;#034;[&amp;#034;] &amp;amp; /@ &#xD;
    If[Length[StringSplit[StringSplit[data, &amp;#034;place&amp;#034;][[k]], &amp;#034;,&amp;#034;]] &amp;gt; 12, Drop[StringSplit[StringSplit[data, &amp;#034;place&amp;#034;][[k]],&amp;#034;,&amp;#034;], {5}], &#xD;
    StringSplit[StringSplit[data, &amp;#034;place&amp;#034;][[k]], &amp;#034;,&amp;#034;]]][[{2, 3, 7, 8, 15}]], {k, 2, Length[StringSplit[data, &amp;#034;place&amp;#034;]]}], Length[Cases[Flatten[#], $Failed]] == 0 &amp;amp;  ], Length[#] == 5 &amp;amp;]];&#xD;
&#xD;
That does look a bit cryptic but gives us what we want. &#xD;
&#xD;
    tab[[1]]&#xD;
&#xD;
gives {10.5673, 59.8929, 13, 80, 1032.9}, wich are the gps coordinates, the temperature in Celsius, the humidity in % and the pressure in mbar. I will now propose three different representations of the data.&#xD;
&#xD;
    scaled = Rescale[tab[[All, 3]]]; &#xD;
    GeoGraphics[Table[{GeoStyling[Opacity[0.99], RGBColor[scaled[[k]], 1 - scaled[[k]], 0]], GeoDisk[{tab[[k, 2]], tab[[k, 1]]}, Quantity[20, &amp;#034;Kilometers&amp;#034;] ]}, {k,1, Length[tab]}]]&#xD;
&#xD;
which gives:&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
The second representation is calculated using &#xD;
&#xD;
    GeoRegionValuePlot[GeoPosition[{#[[2]], #[[1]]}] -&amp;gt; #[[3]] &amp;amp; /@ tab, PlotRange -&amp;gt; {0, 30}, ColorFunction -&amp;gt; &amp;#034;TemperatureMap&amp;#034;, ImageSize -&amp;gt; Full]&#xD;
&#xD;
which looks like this&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
Finally, the lengthy sequence of commands&#xD;
&#xD;
    surface = Interpolation[{{#[[1]], #[[2]]}, #[[3]]} &amp;amp; /@ tab, InterpolationOrder -&amp;gt; 1];&#xD;
    cPlot = Quiet[ContourPlot[surface[x, y], {x, Min[tab[[All, 1]]], Max[tab[[All, 1]]]}, {y, Min[tab[[All, 2]]], Max[tab[[All, 2]]]}, ImagePadding -&amp;gt; None, &#xD;
    ClippingStyle -&amp;gt; None, Frame -&amp;gt; None, Contours -&amp;gt; 60, ContourLines -&amp;gt; False, PlotRange -&amp;gt; {0, 30}, ColorFunction -&amp;gt; &amp;#034;TemperatureMap&amp;#034;]];&#xD;
    multipoly = Polygon[GeoPosition[Join @@ (EntityValue[EntityClass[&amp;#034;Country&amp;#034;, &amp;#034;Europe&amp;#034;], &amp;#034;Polygon&amp;#034;] /. Polygon[GeoPosition[x_]] :&amp;gt; x)]];&#xD;
    GeoGraphics[{GeoStyling[{&amp;#034;GeoImage&amp;#034;, cPlot}], multipoly, Black, Opacity[1]}, ImageSize -&amp;gt; Full]&#xD;
&#xD;
gives this representation&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
I am quite sure that with some modifications one can make a useful program out of this if one uses cloud deploy. Also, netatmo&amp;#039;s data are updated every 30 minutes (every 5 minutes on the individual devices), so one can run a scheduled task and look at the development of the temperature. The large number of netatmo weather stations complements the data available from the Wolfram Data servers very nicely as they provide very up to date street level data.&#xD;
&#xD;
I would be glad to see a good idea of a cloud deployed service based on this or any other ideas that you might have.&#xD;
&#xD;
Cheers,&#xD;
&#xD;
Marco&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com/web/bschelter&#xD;
  [2]: https://www.netatmo.com/en-US/product/weather-station&#xD;
  [3]: /c/portal/getImageAttachment?filename=ScreenShot2014-09-15at22.55.05.png&amp;amp;userId=48754&#xD;
  [4]: http://devices.wolfram.com/devices/netatmo-weather-station.html&#xD;
  [5]: https://www.netatmo.com/weathermap&#xD;
  [6]: /c/portal/getImageAttachment?filename=ScreenShot2014-09-15at22.59.02.png&amp;amp;userId=48754&#xD;
  [7]: /c/portal/getImageAttachment?filename=ScreenShot2014-09-15at22.59.37.png&amp;amp;userId=48754&#xD;
  [8]: https://dev.netatmo.com&#xD;
  [9]: /c/portal/getImageAttachment?filename=netatmofig1.gif&amp;amp;userId=48754&#xD;
  [10]: /c/portal/getImageAttachment?filename=Netatmofig2.gif&amp;amp;userId=48754&#xD;
  [11]: /c/portal/getImageAttachment?filename=Netatmofig3.gif&amp;amp;userId=48754</description>
    <dc:creator>Marco Thiel</dc:creator>
    <dc:date>2014-09-15T22:35:11Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/203498">
    <title>Palette for Inputting Typeset Units and Package with Input Aliases</title>
    <link>https://community.wolfram.com/groups/-/m/t/203498</link>
    <description>I have written a palette and a package to help input properly typeset units.  The palette and package allow for quick input of units in Mathematica, avoiding the clunky units-discovery approach involving Wolfram Alpha queries. As an example, the expression below can be inputted quickly using the palette or by using the input aliases that are loaded by the package.[center][img=width: 206px; height: 89px;]/c/portal/getImageAttachment?filename=InputExample.jpg&amp;amp;userId=23384[/img][/center]The link to a page for downloads is: [url=http://www.blinn.edu/brazos/natscience/phys/thonan/Mathematica/]http://www.blinn.edu/brazos/natscience/phys/thonan/Mathematica/[/url] .</description>
    <dc:creator>Terrence Honan</dc:creator>
    <dc:date>2014-02-20T02:03:07Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/293403">
    <title>Issues with AstronomicalData and SunPosition</title>
    <link>https://community.wolfram.com/groups/-/m/t/293403</link>
    <description>TL;DR
---
I have three issues with getting sun positions in Mathematica V10:

 - It is extremely slow compared to V9
 - It doesn&amp;#039;t *seem* to yield correct results
 - a) It needs an Internet connection, which b) is not assured to always return results and c) if not used optimally can easily consume your monthly allowance of W|A calls

Long story
===
With the advent of V10 `AstronomicalData` has been deprecated, as shown on its documentation page:
![enter image description here][1].

I&amp;#039;m not an astronomer, so my main use of this function has been restricted to its capability to get the sun position using functions calls like this:

    {
      AstronomicalData[&amp;#034;Sun&amp;#034;, {&amp;#034;Azimuth&amp;#034;, {2013, 3, 1, #, 0, 0}, {52.37`, 4.89`}}, TimeZone -&amp;gt; 1], 
      AstronomicalData[&amp;#034;Sun&amp;#034;, {&amp;#034;Altitude&amp;#034;, {2013, 3, 1, #, 0, 0}, {52.37`, 4.89`}},  TimeZone -&amp;gt; 1]
    } &amp;amp; /@ Range[0, 23]

&amp;gt; {{341.47732, -43.93930}, {2.33417, -45.21747}, {22.94232, -43.19133},
&amp;gt; {41.52167, -38.28400}, {57.55208, -31.30276}, {71.47253, -23.03159},
&amp;gt; {84.02194, -14.08294}, {95.91940, -4.92723}, {107.80166, 4.03418}, {120.23770, 12.40167}, {133.72303, 19.72563}, {148.59433, 
&amp;gt;   25.48377}, {164.84179, 29.12209}, {181.93103, 30.19428}, {198.91284,
&amp;gt;    28.55117}, {214.89602, 24.41962}, {229.46400, 
&amp;gt;   18.28613}, {242.70064, 10.70703}, {254.98998, 
&amp;gt;   2.19073}, {266.84760, -6.82566}, {278.85594, -15.94505},  {291.66723, -24.75464}, {306.00911, -32.75641}, {322.57956, 
&amp;gt; -39.29877}}

So, this gets me the sun positions in steps of an hour during a particular day in Amsterdam (TZ 1).

The same call still works in V10, though it now returns numbers with units; degrees in this case. On its first call, it reads some paclet information from a Wolfram server, but on any successive call no Internet connection is needed. I will be going into detail about timing further on, but I&amp;#039;ll say here that the V10 function takes about three times longer than its V9 namesake. I blame the addition of units for that.

With `AstronomicalData` apparently deprecated we are supposed to use its successors. In this case I need `SunPosition`. A direct translation of the above would be:

    SunPosition[GeoPosition[{52.37`, 4.89`}], DateObject[{2013, 3, 1, #, 0, 0}, TimeZone -&amp;gt; 1]] &amp;amp; /@ Range[0, 23]

&amp;gt; {{95.7, -5.1}, {107.6, 3.9}, {120.0, 12.3}, {133.5, 19.6}, {148.3, 25.4}, {164.5, 29.1}, {181.6, 30.2}, {198.6, 28.6}, {214.6, 24.5}, {229.2, 18.4}, {242.5, 10.9}, {254.8, 2.4}, {266.6, -6.7}, {278.6, -15.8}, {291.4, -24.6}, {305.7, 
-32.6}, {322.2, -39.2}, {341.3, -43.5}, {2.0, -44.8}, {22.5, -42.9}, 
{41.1, -38.0}, {57.1, -31.1}, {71.0, -22.9}, {83.6, -13.9}}

As with the new `AstronomicalData` the output is actually in degrees which I have removed in the above output for the sake of clarity. There are a few things to note:

 - `SunPosition` uses position and date objects, the latter being new in V10
 - `SunPosition` does not have a `TimeZone` option, but you can set it in `DateObject`
 - `SunPosition` can use the old lat/long list position indication. It also can use a date list to enter the date instead of a `DateObject`. In the latter case you are out of options with respect to time zones and you have to add the appropriate amount of time offset
 - It is extremely slow, and it may even time-out: 

![enter image description here][2]

 - Last but not least: the results seem to be plain wrong. It suggests that sunrise is somewhat before 1 am, which is -of course- incorrect. I assume that this has something to do with a `$GeoLocation` setting for the observer of the sun positions, but I haven&amp;#039;t managed to sort out what I am supposed to enter to get the correct sun positions for the location provided in the same call.

As to timing: I noticed very inconsistent timings for `SunPosition` compared to `AstronomicalData`, so I used the following code to collect a somewhat more statistical  sound sample:

    SetAttributes[timingTest, HoldFirst];
    timingTest[code_, repeats_Integer] :=
       Table[
          ClearSystemCache[];
          code // AbsoluteTiming // First,
          {repeats}
        ]

Using this, I collected timing of 20 calls to the following code snippets:

 - `AstronomicalData` V9 and V10: As above
 - `SunPosition`: As above
 - `SunPosition` without `GeoPosition`, just the lat/long list.
 - `SunPosition`  without `GeoPosition`, and also without the `DateObject` date, just a classical date list (with the hour set to +1 to accommodate TZ 1)
 - `SunPosition` V10 without `GeoPosition` and with the `Map` (`/@`) gone and replaced by a `DateRange` inside the call.

In the last case, the returned value is a `TimeSeries` object from which I extract the positions using the `&amp;#034;Paths&amp;#034;` method:

     SunPosition[{52.37`, 4.89`}, DateRange[{2013, 3, 1, 1, 0, 0}, {2013, 3, 1, 24, 0, 0}, &amp;#034;Hour&amp;#034;]][&amp;#034;Paths&amp;#034;][[1, All, 2]]

The results were as follows:

![enter image description here][3]

Clearly, the `SunPosition` results are very disappointing. Getting the sun positions with `SunPosition` is almost 40 times slower than using the old V9 method (which, I should add, wasn&amp;#039;t particularly quick either. I have an implementation in Mathematica code which is faster). The V10 implementation of `AstronomicalData` is also more than three times slower than the V9 version. The `DateRange` version of the call saves a lot of communication overhead. Still, it is almost *five times slower* than in V9.

The cause of all this slowness is that `SunPosition` simply does a call to Wolfram|Alpha. Sniffing the communication one sees the following string passed to the server:

    &amp;#034;1:eJxTTMoPSuNgYGAoZgESPpnFJcHcQEZwaV5AfnFmSWZ+XhoTsmxR/6GvGjH9wg4Qhr6XQxobsnzmXXYGhkxmIC+TEUSIgwggZihigIJgoAIGj/yizKr8PJigA5yBZtubwB1yrdxeDkXVIuvcH1aJOBRzAqUcS0vycxNLMpMBSAArww==&amp;#034;

which can be turned into readable form using `Uncompress`:

    {&amp;#034;SunPosition&amp;#034;, {4.89, 52.37}, {2013, 3, 1, 23, 0, 0.}, &amp;#034;Horizon&amp;#034;, 2., 2., {52.09, 5.12}, Automatic}

Here, we can recognize the lat/long of the position I used (but with lat/long reversed - Is this somehow significant?). At the end is my own `$GeoLocation`, but I don&amp;#039;t believe it is used at all (and it shouldn&amp;#039;t: I&amp;#039;m asking for the sun position over Amsterdam, not where I live). Changing it with `Block` I get the same results:

    Block[{$GeoLocation = GeoPosition[{52.37`, 40.89`}]}, SunPosition[{52.37`, 4.89`}, {2013, 3, 1, 1, 0, 0}]]

Apart from the slowness, there&amp;#039;s the issue of the necessary Internet connectivity (Want to give a demonstration and you don&amp;#039;t have Internet? Sorry, you&amp;#039;re out of luck). 

And what of the use of W|A calls? Each of the `SunPosition` tests (except the last one) took me 20 * 24 = 480 calls. So this part of my testing only already took 1440 calls, and one should be reminded that a typical Home Use license allows for only 3,000 calls per month. Things like this can go pretty fast. In fact, I once wrote an application that calculates the impact of building changes on shadows around your house throughout the year. It does in the order of 17,000 `AstronomicalData` calls. I couldn&amp;#039;t implement that naively using `SunPosition` and have it actually work. Clearly, one should now use the `DateRange` version of the call as much as possible.

----------

To wrap up: I have one real question, i.e., how to get `SunPosition` to return the same values as `AstronomicalData`, and a request to the WRI team: please put `SunPosition` in the kernel and don&amp;#039;t use W|A calls, because the situation as it is now is rather annoying and IMHO a real step backwards.

  [1]: /c/portal/getImageAttachment?filename=AstronomicalData.png&amp;amp;userId=43903
  [2]: /c/portal/getImageAttachment?filename=timeout.png&amp;amp;userId=43903
  [3]: /c/portal/getImageAttachment?filename=results.png&amp;amp;userId=43903</description>
    <dc:creator>Sjoerd de Vries</dc:creator>
    <dc:date>2014-07-13T16:39:48Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/553861">
    <title>Wolfram Data Drop IFTTT Channel: track your elevation and much more</title>
    <link>https://community.wolfram.com/groups/-/m/t/553861</link>
    <description>Yesterday [IFTTT][1] (IF This Then That) released the [Wolfram Data Drop Channel][2]. This is a BIG step forward in making the data from the Internet of Things computable. Currently there are more than [150 trigger channels][3] that can be connected to [Data Drop][4]. Let&amp;#039;s take a look at one of those channels: [Numerous][5]. In this post I&amp;#039;ll show you how to get a Numerous recipe running in a few simple steps.&#xD;
&#xD;
- Sign in to [https://ifttt.com][6]. Go to My Recipes. Click &amp;#034;Create Recipe&amp;#034;&#xD;
&#xD;
![Click Create Recipe][7]&#xD;
&#xD;
- Step 1: Select the Numerous Trigger Channel&#xD;
&#xD;
![Choose Trigger][8]&#xD;
&#xD;
 - Step 2: Select the trigger that fires every time a number changes by any amount&#xD;
&#xD;
![chooseType][9]&#xD;
&#xD;
 - Step 3: Select the number that you want to track, elevation in my case&#xD;
&#xD;
![Select number][10]&#xD;
&#xD;
 - Step 4: Select Wolfram Data Drop as Your Action Channel&#xD;
&#xD;
![then action][11]&#xD;
![data drop channel][12]&#xD;
&#xD;
 - Step 5: Select &amp;#034;Add entry&amp;#034; Action&#xD;
&#xD;
![add entry][13]&#xD;
&#xD;
 - Step 6: Complete Action Fields&#xD;
&#xD;
![action fields][14]&#xD;
&#xD;
Use the Wolfram Language function [CreateDatabin][15] to provide a name, and to specify that we want the values of the entries to be interpreted as a physical quantities (feet in this case).&#xD;
&#xD;
    bin = CreateDatabin[&amp;lt;|&amp;#034;Name&amp;#034; -&amp;gt; &amp;#034;My Elevation&amp;#034;|&amp;gt;, &#xD;
    &amp;#034;Interpretation&amp;#034; -&amp;gt; {&amp;#034;elevation&amp;#034; -&amp;gt;Restricted[&amp;#034;StructuredQuantity&amp;#034;,&amp;#034;Feet&amp;#034;]}];&#xD;
    bin[&amp;#034;ShortID&amp;#034;]&#xD;
**&amp;#034;6F9_LE8T&amp;#034;**&#xD;
&#xD;
 - Copy-paste this ID&#xD;
&#xD;
 - Write *elevation=* and select the ingredient **FormattedValue**.&#xD;
&#xD;
![ingredient][17]&#xD;
&#xD;
    elevation={{FormattedValue}}&#xD;
&#xD;
 - Step 7: Create and Connect&#xD;
&#xD;
![create][18]&#xD;
&#xD;
Voilà!&#xD;
======&#xD;
![Numerous recipe][19]&#xD;
&#xD;
Now you can take an insight of the elevation measurements with [Wolfram|Alpha][20] by entering *Data drop* along with your databin&amp;#039;s *ID*.&#xD;
**Data drop 6F9_LE8T** in my case.&#xD;
&#xD;
![WA][21]&#xD;
&#xD;
Or you can access this data directly from the Wolfram Language:&#xD;
&#xD;
    DateListPlot[Databin[&amp;#034;6F9_LE8T&amp;#034;], Filling -&amp;gt; Bottom, FillingStyle -&amp;gt; LightBrown]&#xD;
&#xD;
![WLelevation][22]&#xD;
&#xD;
Please, feel free to share your own recipes below. Enjoy!&#xD;
&#xD;
&#xD;
  [1]: https://ifttt.com/wtf&#xD;
  [2]: https://ifttt.com/wolfram_data_drop&#xD;
  [3]: https://ifttt.com/channels&#xD;
  [4]: https://datadrop.wolframcloud.com/&#xD;
  [5]: https://ifttt.com/numerous&#xD;
  [6]: https://ifttt.com&#xD;
  [7]: /c/portal/getImageAttachment?filename=createRecipe.png&amp;amp;userId=56204&#xD;
  [8]: /c/portal/getImageAttachment?filename=1.png&amp;amp;userId=56204&#xD;
  [9]: /c/portal/getImageAttachment?filename=2v.png&amp;amp;userId=56204&#xD;
  [10]: /c/portal/getImageAttachment?filename=2.png&amp;amp;userId=56204&#xD;
  [11]: /c/portal/getImageAttachment?filename=3.png&amp;amp;userId=56204&#xD;
  [12]: /c/portal/getImageAttachment?filename=3v.png&amp;amp;userId=56204&#xD;
  [13]: /c/portal/getImageAttachment?filename=4.png&amp;amp;userId=56204&#xD;
  [14]: /c/portal/getImageAttachment?filename=6v1.png&amp;amp;userId=56204&#xD;
  [15]: https://reference.wolfram.com/language/ref/CreateDatabin.html&#xD;
  [16]: /c/portal/getImageAttachment?filename=6v4.png&amp;amp;userId=56204&#xD;
  [17]: /c/portal/getImageAttachment?filename=6v5.png&amp;amp;userId=56204&#xD;
  [18]: /c/portal/getImageAttachment?filename=7.png&amp;amp;userId=56204&#xD;
  [19]: /c/portal/getImageAttachment?filename=recipe.png&amp;amp;userId=56204&#xD;
  [20]: https://www.wolframalpha.com/input/?i=Data+drop+6F9_LE8T&#xD;
  [21]: /c/portal/getImageAttachment?filename=WAelev.png&amp;amp;userId=56204&#xD;
  [22]: /c/portal/getImageAttachment?filename=WLelevation.png&amp;amp;userId=56204</description>
    <dc:creator>Bernat Espigulé</dc:creator>
    <dc:date>2015-08-26T16:55:04Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/775253">
    <title>Degrees instead of radians</title>
    <link>https://community.wolfram.com/groups/-/m/t/775253</link>
    <description>If I for instance change rectangular to polar coordinate it comes out like this:&#xD;
&#xD;
    ToPolarCoordinates[{15, 20}]&#xD;
    {25, ArcTan[4/3]}&#xD;
&#xD;
Can anyone tell me how to get this in degrees? So far I&amp;#039;ve tried this, which is described in the documentation under &amp;#034;Radian&amp;#034; Convert[n Radian,newunits] converts n Radian to a form involving units newunits.:&#xD;
&#xD;
    Convert[ArcTan[4/3] Radian, Degree]&#xD;
    Convert[ArcTan[4/3], °]&#xD;
&#xD;
Thanks!</description>
    <dc:creator>Benny Bomstærk</dc:creator>
    <dc:date>2016-01-18T22:34:52Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/844216">
    <title>Convert 1040 Seconds Into 17 Minutes and 20 Seconds?</title>
    <link>https://community.wolfram.com/groups/-/m/t/844216</link>
    <description>Hello,&#xD;
&#xD;
I have a basic question which I cannot find the answer to:&#xD;
How do I make Mathematica convert 1040 seconds into 17 minutes and 20 seconds?  I want Mathematica to give me the conversion with one command or cell input.  I would also like for the output to have the words &amp;#034;minutes&amp;#034; and &amp;#034;seconds&amp;#034; if possible.&#xD;
&#xD;
Thanks.</description>
    <dc:creator>Dan M</dc:creator>
    <dc:date>2016-04-22T10:07:25Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/745753">
    <title>Why doesn&amp;#039;t Quantity[] and related functions work for me?</title>
    <link>https://community.wolfram.com/groups/-/m/t/745753</link>
    <description>I&amp;#039;m a new user of MMA ver. 10.3.0 Home Edition. I&amp;#039;m trying to learn how to use Units, but it&amp;#039;s not working. For example&#xD;
&#xD;
    In[47]:= UnitConvert[Quantity[12, &amp;#034;Meters&amp;#034;/&amp;#034;Seconds&amp;#034;], &amp;#034;Miles&amp;#034;/&amp;#034;Hours&amp;#034;]&#xD;
    &#xD;
    Out[47]= UnitConvert[&#xD;
     QuantityUnits`Private`ToQuantity[&#xD;
      QuantityUnits`Private`UnknownQuantity[12, (&amp;#034;Meters&amp;#034;)/(&#xD;
       &amp;#034;Seconds&amp;#034;)]], (&amp;#034;Miles&amp;#034;)/(&amp;#034;Hours&amp;#034;)]&#xD;
&#xD;
If I load the Units` package I get the answer I seek:&#xD;
&#xD;
    In[48]:= &amp;lt;&amp;lt; Units`&#xD;
    &#xD;
    Convert[12  Meter/Second, Mile/Hour]&#xD;
    &#xD;
    Out[49]= (37500 Mile)/(1397 Hour)&#xD;
&#xD;
But starting with ver 9 I shouldn&amp;#039;t have had to do that. Any ideas about what&amp;#039;s going on?</description>
    <dc:creator>Victor Bloomfield</dc:creator>
    <dc:date>2015-11-27T05:01:46Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1747298">
    <title>Radians as Dimensionless Unit?</title>
    <link>https://community.wolfram.com/groups/-/m/t/1747298</link>
    <description>I&amp;#039;m using Mathematica to teach a Physics course (Theoretical Mechanics) this fall, and am having lots of trouble with units (Quantity...). My most recent issue is this: Mathematica doesn&amp;#039;t seem to recognize that Radians are a dimensionless unit. So if I type:&#xD;
&#xD;
    QuantityMagnitude[5, &amp;#034;Radians&amp;#034;]&#xD;
I get the error message: Quantity::compat: DimensionlessUnit and Radians are incompatible units&#xD;
&#xD;
You might wonder why I would like to do something like this anyway. The issue is that NDSolve doesn&amp;#039;t seem to work with Quantities, so I need to strip units off of everything before running it through there. But if I have an angle, I don&amp;#039;t know if it is in Degrees, Radians or without any specific angular unit which means the dimensionless angular unit of Radians if coming out of some calculation like &#xD;
&#xD;
    \[Phi] = \[Sqrt](k/m) t&#xD;
&#xD;
Is there some way for me to tell Mathematica that Radians are compatible with DimensionlessUnit? Or do I need to write some wrapper that checks if compatible and if not then don&amp;#039;t try to convert?&#xD;
&#xD;
Thanks,&#xD;
Eric</description>
    <dc:creator>Eric Hudson</dc:creator>
    <dc:date>2019-07-29T14:14:35Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1899870">
    <title>[NB] Visualizing the Epidemic Data COVID-19</title>
    <link>https://community.wolfram.com/groups/-/m/t/1899870</link>
    <description>*MODERATOR NOTE: coronavirus resources &amp;amp; updates:* https://wolfr.am/coronavirus&#xD;
&#xD;
----------&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
![enter image description here][1]&#xD;
![enter image description here][2]&#xD;
![enter image description here][3]&#xD;
&#xD;
&#xD;
There are many much more sophisticated models out there using the COVID-19 data but i wanted a simple overview of the data to monitor the progression of the countries and do some comparisons.&#xD;
. &#xD;
Therefore i made a simple plot interface of the Infected and deaths of the countries which can be plotted linear and logarithmic. i chose to align all the data to day 0 which is defined as the first day of &amp;gt;100 confirmed infected cases in a country. This makes comparison of countries in their early stage to more affected countries more intuitive.   &#xD;
&#xD;
To fill my own curiosity i have added sigmoidal fits to data to see the &amp;#034;prediction&amp;#034;, which only becomes reliable once a tipping point in controlling the disease is reached. I also calculate the mortality of the confirmed cases. I have chosen to only include the first 20 most affected countries but changing the included countries is easy. The interface allows to turn on and off countries to make comparisons.&#xD;
&#xD;
Hope its also useful to others.&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][4]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=COVID-3.PNG&amp;amp;userId=1332602&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=COVID-2.PNG&amp;amp;userId=1332602&#xD;
  [3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=COVID-1.PNG&amp;amp;userId=1332602&#xD;
  [4]: https://www.wolframcloud.com/obj/be9243ef-6580-442f-9fbf-764b515d577e</description>
    <dc:creator>Martijn Froeling</dc:creator>
    <dc:date>2020-03-17T14:00:10Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1862464">
    <title>Using Pseudo-Hilbert Curves to Assist People Perceive Images via Sound</title>
    <link>https://community.wolfram.com/groups/-/m/t/1862464</link>
    <description>###Introduction###&#xD;
Recently, I was learning about infinite space filling curves and their applications in real life. I became fascinated with [Hilbert Curves][1], one of many [plane-filling functions][2]. I wanted to see how these shapes could be used in image to video conversion. To begin with, I explored how pseudo Hilbert Curves could be used to convert a square image to audio so that each pixel color was associated with a specific sound. &#xD;
&#xD;
Theoretically, a person would be able to learn this association and would be able to reconstruct a mental image by listening to audio. This could help with people who are visually impaired, letting blind people &amp;#034;hear&amp;#034; pictures. The reverse is also true. People who are deaf will be able to &amp;#034;see&amp;#034; sound. &#xD;
&#xD;
I thought I could implement this using Mathematica, which I learned last summer at the Wolfram High School Camp.&#xD;
&#xD;
###Why Hilbert Curves###&#xD;
![Pseudo-Hilbert Curves from Order 1 to 10][3]&#xD;
As you can see above, as you increase the order, the limit of these curves start to fill an infinite amount of space. A true Hilbert Curve is actually $\lim_{n\to\infty} PseudoHilbertCurve_n$. Each one of these curves can be used on an image of dimensions 2 by 2, 4 by 4, 8 by 8, etc. The curve needed is accordingly:&#xD;
&#xD;
    HilbertCurve[Log[2, ImageDimensions[image]]]&#xD;
&#xD;
Each line in the curve will go over one pixel in the image, starting at the bottom left and ending at the bottom right. &#xD;
&#xD;
![Example of Order 3 Pseudo Hilbert Curve][4]&#xD;
&#xD;
But why would you need to use this specific pattern, as supposed to something more simple? Here: https://youtu.be/3s7h2MHQtxc?t=355. In short, if you were to increase the resolution of your image, you would now have to retrain your brain to re-associate the pixel value and the associated frequency at that point on the image. But this is not the case on a Hilbert Curve. As you increase the resolution of your image, and thus the order pseudo-Hilbert Curve, a point will just move closer and closer to its limit in the same space, which solves our problem.&#xD;
&#xD;
###Converting Color to Sound###&#xD;
This was the main hurdle when writing the program. I needed to convert each pixel value to a unique sound frequency. My initial thought was to just create an association between each wavelength in the visible electromagnetic spectrum and a frequency, but I was quick to learn that doesn&amp;#039;t work in the digital world. RGB colors could be a combination of different wavelengths. And I couldn&amp;#039;t just add these wavelengths separately because there could be overlap. There was also brightness and darkness which isn&amp;#039;t part of the light spectrum. So instead of the RGB format, I decided to use the HSB format (hue, saturation, and brightness). This is also more compatible for human learning, as the human eye uses these three characteristics to determine color, as supposed to the RGB values on a computer image.&#xD;
&#xD;
![Graphics3D Visualizer of HSB][5]&#xD;
&#xD;
As you can see from the image, Hue could be used to determine the color. Now, instead of RGB with three values to one color, Hue gave me one number to a specific color. &#xD;
&#xD;
![Graphics Hue Color Chart][6]&#xD;
&#xD;
But I still needed to show saturation and brightness in my sound waves. Color in a computer is expressed in three dimensions while sound has two: amplitude and frequency. I would be leaving one color property out. I could think of multiple ways to express all three as sound waves, but none of them made sure that similar colors sounded the same. For example, if I had a hue playing a certain frequency, I could define a range around this point that could express either saturation or brightness using a plus/minus system. &#xD;
&#xD;
To solve this, I decided to use [AudioChannel][7] functions. This way, one channel could express the hue through a specific frequency, while the other channel could express the saturation and brightness combined through volume and frequency respectively. This way, colors that were similar would sound similar too.&#xD;
&#xD;
###Creating the Function###&#xD;
Obviously, I needed to get real images. I used *image1*, where the pixels were easily noticeable, and my baby picture for the school yearbook as *image2*, as a test image. The first one, being resized to a 8 by 8 image, would utilize an order 3 pseudo-Hilbert Curve ($\log _{2}8=3$), and the second one, being resized to a 32 by 32 image, would utilize an order 5 pseudo-Hilbert Curve ($\log _{2}32=5$).&#xD;
&#xD;
![The images I used to test the program.][8]&#xD;
&#xD;
To get the HSB values, I used Wolfram&amp;#039;s in-built [Hilbert Curve][9] and [Pixel Value][10] functions. I used Pixel Value to read the image&amp;#039;s pixel values as bytes, which was converted to RGB and then to HSB. To get the points on the Hilbert Curve that was associated with their respective position on the image, I added {1,1} to each point so that it matched the pixel space (the origin on a Cartesian Plane is designated as (1,1) on an image).&#xD;
&#xD;
    getHSB[image_] := &#xD;
     ColorConvert[&#xD;
      RGBColor /@ &#xD;
       Divide[PixelValue[&#xD;
         image, ({1, 1} + #) &amp;amp; /@ &#xD;
          HilbertCurve[Log[2, ImageDimensions[image][[1]]]][[1]], &amp;#034;Byte&amp;#034;],&#xD;
         255.], &amp;#034;HSB&amp;#034;]&#xD;
&#xD;
In the Wolfram Language, HSB values range from 0 to 1 instead of the normal 0 to 360 which I guess gives the user more control of the specific color they want to implement. I had to scale these values to the frequency range I wanted for the hue and brightness. Through trial and error, I decided that 100-3900 Hz was a good range so that people of all ages could hear the lowest and highest frequencies. For the amplitude dictated by the saturation, I could just use the direct value as [SoundVolume][11]. I made it so that the sound for each pixel had a duration of 0.1 seconds for demonstrative purposes. In the real world, I would think that this should be a lot smaller so that images don&amp;#039;t take too long to hear. &#xD;
&#xD;
    getHSB[image_] := &#xD;
     ColorConvert[&#xD;
      RGBColor /@ &#xD;
       Divide[PixelValue[&#xD;
         image, ({1, 1} + #) &amp;amp; /@ &#xD;
          HilbertCurve[Log[2, ImageDimensions[image][[1]]]][[1]], &amp;#034;Byte&amp;#034;],&#xD;
         255.], &amp;#034;HSB&amp;#034;]&#xD;
    hueToFrequencyMatch[HSB_] := Rescale[HSB[[1]], {0, 1}, {100, 3900}]&#xD;
    saturationToAmplitudeMatch[HSB_] := HSB[[2]]&#xD;
    brightnessToFrequencyMatch[HSB_] := &#xD;
     Rescale[HSB[[3]], {0, 1}, {100, 3900}]&#xD;
    soundFrequency[frequency_] := &#xD;
     Sound[Play[Sin[frequency*2 Pi t], {t, 0, 0.1}]]&#xD;
    soundFrequencyVolume[frequency_, ampSaturation_] := &#xD;
     Sound[soundFrequency[frequency], SoundVolume -&amp;gt; ampSaturation]&#xD;
&#xD;
After this, I just had to apply these functions over the HSB values of each pixel in the order dictated by the appropriate pseudo-Hilbert Curve, and then merge the hue sound and saturation+brightness sound as separate audio channels. &#xD;
&#xD;
    convertHToSound[image_] := &#xD;
     soundFrequency /@ hueToFrequencyMatch /@ getHSB[image] // AudioJoin&#xD;
    convertBSToSound[picture_] :=&#xD;
     (soundList = {}; n = 1;&#xD;
      While[n &amp;lt;= Length@getHSB[picture],&#xD;
       AppendTo[soundList, &#xD;
        soundFrequencyVolume[&#xD;
         getHSB[picture][[n]] // brightnessToFrequencyMatch, &#xD;
         getHSB[picture][[n]] // saturationToAmplitudeMatch]];&#xD;
       n++])&#xD;
    convertHSBToSound[audio1_, audio2_] := &#xD;
     AudioChannelCombine[{audio1, audio2}]&#xD;
&#xD;
Because hue is the most important color characteristic, I wanted to emphasize this AudioChannel more. Thus,&#xD;
&#xD;
    editChannel2[audio_, factor_] := AudioPan[audio, -factor]&#xD;
&#xD;
To put everything together, I made a separate function to organize the results.&#xD;
&#xD;
    seperateTable[picture_] :=&#xD;
     (convertBSToSound[picture];&#xD;
      Module[{a = convertHToSound[picture], b = soundList // AudioJoin},&#xD;
       c = editChannel2[convertHSBToSound[a, b], 0.05];&#xD;
       table = &#xD;
        Grid[{{Image[picture, ImageSize -&amp;gt; 100], a, b, c}, {Blank[], &#xD;
           AudioPlot@a, AudioPlot@b, AudioPlot@c}}];&#xD;
       ReplacePart[table, &#xD;
        1 -&amp;gt; Prepend[&#xD;
          First[table], {&amp;#034;Image&amp;#034;, &amp;#034;Hue&amp;#034;, &amp;#034;Saturation+Brightness&amp;#034;, &#xD;
           &amp;#034;HSB&amp;#034;}]]])&#xD;
&#xD;
These were my results. I will attach the *hsb1* and *hsb2* sound files to this post, along with my notebook. &#xD;
&#xD;
![Final image to sound representation.][12]&#xD;
Because they use two channels, you should use earbuds or headphones so that you can clearly differentiate the sounds coming through your left and right ears.&#xD;
![Spectrogram of *hsb1* and *hsb2*][13]&#xD;
&#xD;
###Visualizing the Process###&#xD;
&#xD;
    animate[image_, audio_] :=&#xD;
        Module[{list = ({1, 1} + #) &amp;amp; /@ &#xD;
        HilbertCurve[Log[2, ImageDimensions[image][[1]]]][[1]]},&#xD;
      (AudioPlay@audio;&#xD;
       Animate[&#xD;
        ReplacePixelValue[Image[image, ImageSize -&amp;gt; 100], &#xD;
         list[[1 ;; index]] -&amp;gt; Orange],&#xD;
        {index, 1, list // Length, 1}, &#xD;
        DefaultDuration -&amp;gt; &#xD;
         QuantityMagnitude[&#xD;
          UnitConvert[Quantity[audio // Duration, &amp;#034;Seconds&amp;#034;]]], &#xD;
        AnimationRepetitions -&amp;gt; 1])]&#xD;
&#xD;
I used this to create the following two animations. If you ran these programs, the HSB sound would play alongside the animation, showing exactly which pixel correlates to each sound. Unfortunately, I couldn&amp;#039;t play the audio here on the post, but it is in the attached notebook if you would like to see. Here is what it looks like:&#xD;
&#xD;
![*hsb1* Conversion][14]&#xD;
![*hsb2* Conversion][15]&#xD;
&#xD;
###Future Work###&#xD;
In the future, I hope to create a machine learning algorithm that can learn this association between audio and image in reverse (recreate the image from audio). If anyone has any ideas or pointers for me, please share in the comments below - I would really appreciate it!&#xD;
&#xD;
##Updated Information:##&#xD;
Presented work at the [New Hampshire Science &amp;amp; Engineering Expo][16] and won the Office of Naval Research award.&#xD;
&#xD;
Youtube Link: [Video Presentation][17]&#xD;
&#xD;
&#xD;
  [1]: http://mathworld.wolfram.com/HilbertCurve.html&#xD;
  [2]: http://mathworld.wolfram.com/Plane-FillingFunction.html&#xD;
  [3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-01-19at12.07.19PM.png&amp;amp;userId=1725131&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=example.gif&amp;amp;userId=1725131&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=HSB.png&amp;amp;userId=1725131&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Hue.png&amp;amp;userId=1725131&#xD;
  [7]: https://reference.wolfram.com/language/ref/AudioChannels.html&#xD;
  [8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-01-19at1.39.00PM.png&amp;amp;userId=1725131&#xD;
  [9]: https://reference.wolfram.com/language/ref/HilbertCurve.html&#xD;
  [10]: https://reference.wolfram.com/language/ref/PixelValue.html&#xD;
  [11]: https://reference.wolfram.com/language/ref/SoundVolume.html&#xD;
  [12]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-01-19at2.23.47PM.png&amp;amp;userId=1725131&#xD;
  [13]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2020-01-19at2.32.49PM.png&amp;amp;userId=1725131&#xD;
  [14]: https://community.wolfram.com//c/portal/getImageAttachment?filename=animation1.gif&amp;amp;userId=1725131&#xD;
  [15]: https://community.wolfram.com//c/portal/getImageAttachment?filename=animation2.gif&amp;amp;userId=1725131&#xD;
  [16]: https://nhsee.org/&#xD;
  [17]: https://youtu.be/gwpK2KIfVmA</description>
    <dc:creator>Srinath Rangan</dc:creator>
    <dc:date>2020-01-19T19:42:34Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2134507">
    <title>Solve and NSolve not working well with Quantity and Units?</title>
    <link>https://community.wolfram.com/groups/-/m/t/2134507</link>
    <description>I am trying to update 100k lines of Mathematica I wrote&#xD;
15-20 years ago in Version 4. I am struggling with getting Quantity,&#xD;
Solve/NSolve and Integrate to correctly deal with units. Solve/NSolve &#xD;
always return the correct numerical values, but the &amp;#034;Units&amp;#034; are quite often lost. I can&#xD;
not figure out why. But it seems related to the Integrate function and places&#xD;
where variable definitions first appear in the code as arguments&#xD;
to the Quantity function. The Plus function may also be failing. Also of note,&#xD;
is how &amp;#034;unit-less&amp;#034; variable name definitions seem the direct cause of the errors produced by the Integrate function. And perhaps at the root of my programming dilemma is the way multiplying a scalar Quantity by zero wrongly preserves Units. &#xD;
&#xD;
In V4:&#xD;
&#xD;
       200 kg times 0 equals 0&#xD;
&#xD;
In V12&#xD;
&#xD;
       200 kg times 0 equals 0 kg&#xD;
&#xD;
This bug/feature, breaks simple vector calculus computations in countless ways. See the detailed examples given far below in this thread, where V12&amp;#039;s forcing of units on values of zero magnitude causes simple exercises in Newtonian Mechanics to &amp;#034;blow up&amp;#034;.&#xD;
&#xD;
&#xD;
 Any help would be appreciated. &#xD;
See attached notebook for examples of this behavior. JPEG attached for&#xD;
easy demonstration of typesetting. Code is in the attached notebook.&#xD;
&#xD;
    &#xD;
    \!\(\*OverscriptBox[\(a\), \(\[RightVector]\)]\) = {Quantity[0, (&#xD;
        &amp;#034;Meters&amp;#034;)/(&amp;#034;Seconds&amp;#034;)^2], Quantity[0, (&amp;#034;Meters&amp;#034;)/(&amp;#034;Seconds&amp;#034;)^2]};&#xD;
&#xD;
![Solve not returning Units][1]&#xD;
&#xD;
&#xD;
![NSolve working almost correctly][2]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=SolvenotreturningUnits.JPG&amp;amp;userId=2125101&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ExampleofNSolveworkingcorrectlywithQuantify.JPG&amp;amp;userId=2125101</description>
    <dc:creator>Francis Bush</dc:creator>
    <dc:date>2020-12-10T00:20:52Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1260622">
    <title>Convert Radian to Degree?</title>
    <link>https://community.wolfram.com/groups/-/m/t/1260622</link>
    <description>Hi all,&#xD;
&#xD;
I have a list of Rad angles {-1.69347, 1.70849, 0.181325, -1.69539, 1.73843, 0.357308, etc} and I want to convert it to 0 360 Degree. Can anyone help? If I just  {-1.69347, 1.70849, 0.181325, -1.69539, 1.73843, 0.357308} / Degree, it will become {-97.029, 97.8892, 10.3892, -97.1386, 99.6046, 20.4723}. I want to add only those negative angles in the list by 360 Degree.&#xD;
&#xD;
Thanks</description>
    <dc:creator>Thong Ly</dc:creator>
    <dc:date>2018-01-06T15:45:56Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/3389913">
    <title>Is asteroid 2024 YR4 going to hit Earth in 2032?</title>
    <link>https://community.wolfram.com/groups/-/m/t/3389913</link>
    <description>![Is asteroid 2024 YR4 going to hit Earth in 2032? Numeric n-body simulation, NASA data, gravitational interactions, astronomical data.][1]&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][2]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=fin_astero-ezgif.com-optimize.gif&amp;amp;userId=20103&#xD;
  [2]: https://www.wolframcloud.com/obj/6ec5ebb8-fdbb-4705-b942-8514e3e827ec</description>
    <dc:creator>Jeffrey Bryant</dc:creator>
    <dc:date>2025-02-09T07:38:44Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/133220">
    <title>Exporting dimensionally accurate images in PDF format with margins?</title>
    <link>https://community.wolfram.com/groups/-/m/t/133220</link>
    <description>I need to generate a pdf image file that is dimensionally accurate for print-out into a hard copy. In addition, I need to accurately specify of the margins around the printed image. Here is an simple test example of a possible solution (that does not seem to work correctly):
[mcode]
SetDirectory[NotebookDirectory[]];

{xsize,ysize} = {7,9}; (*scale is in inches*)

{{left,right},{bottom,top}} = {{1/4.,8.5-xsize-1/4.},{1/2.,11-ysize-1/2.}}; (*scale is in inches*)

Export[&amp;#034;TestPDFNotebook.pdf&amp;#034;,
Rasterize[Graphics[Line[72*{{0,0},{0,ysize},{xsize,ysize},{xsize,0},{0,0}}]],
ImageSize-&amp;gt;{xsize,ysize}*72], ImageSize-&amp;gt;{xsize,ysize}*72, ImageMargins-&amp;gt;Floor[72.*{{left,right},{bottom,top}}]] (*scale is now in printer points*)
[/mcode]
Note that here I am using Export to generate a pdf file of a bitmapped image that is created with Rasterize. In addition, I am using the ImageSize option to specify the intended image size during printout. I am also using the ImageMargins options to specify margin widths. Both ImageSize and ImageMargins have units of printer points (72 pnts/inch). The intended paper size is 8.5 x 11 inches. The intended image size in this example is 7 inches x 9 inches. Unfortunately the image dimensions are completely lost during printout. Why is this happening? and more importantly, how to fix it?</description>
    <dc:creator>Donald Barnhart</dc:creator>
    <dc:date>2013-10-01T20:58:24Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/292343">
    <title>Formatting units and subscripts for readable output and code</title>
    <link>https://community.wolfram.com/groups/-/m/t/292343</link>
    <description>Like many engineers my calculations have to be readable to others that do not use Mathematica. There are standard ways of representing variables and units which make the calculations readable and give a certain familarity which helps to spot errors etc. There are two particular items that give trouble in trying to achieve this. With units I have been able to create my own abbreviated unit definitions e.g.. kN for kiloNewton and m for metres. However, UnitConvert insists on converting to its own form rather than the form I want e.g.. m N rather than kNm. Is there away to force it to give you the units you want? This used to work well in &amp;#034;Automatic Units&amp;#034; but &amp;#034;Automatic Units&amp;#034; does not seem to work with v.10. &#xD;
&#xD;
The second problem is subscripts. I need a very large number of symbols that have subscripts. It is convenient to use the Symbolize function to produce these when needed. However, I then run into trouble when I want to use subscripts as indices of lists. Is there any way over this?&#xD;
&#xD;
I have attached a notebook which explains what I want with a couple of trivial examples as I do not seem to be able to post nicely formatted Mathematica code in here when it contains subscripts etc.</description>
    <dc:creator>Malcolm Woodruff</dc:creator>
    <dc:date>2014-07-12T13:24:05Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/430038">
    <title>How to utilize the material properties inside Mathematica?</title>
    <link>https://community.wolfram.com/groups/-/m/t/430038</link>
    <description>Hello everyone,&#xD;
&#xD;
I have questions regarding properties stored inside Mathematica.&#xD;
I am a master student researching on heat transfer.&#xD;
As I found out that Mathematica itself have data related to the thermodynamic data for the materials, for example, steel, aluminium, water, ammonia and others. I would like to use the data for my calculations. But the problem is that, the properties are dependant on the temperatures of the material itself (though, for heat conductivity, does not change much in the range of 300 K to 400 K).&#xD;
&#xD;
Now how do I extract data for the properties for different temperature?&#xD;
For example, thermal conductivity for aluminium for the range of 100 K to 1000 K.&#xD;
&#xD;
What I have learned is how to find the properties of Air, for room temperature?&#xD;
ThermodynamicData[&amp;#034;Air&amp;#034;, &amp;#034;ThermalConductivity&amp;#034;]&#xD;
&#xD;
Thank you very much for your help.</description>
    <dc:creator>Thai Kee Gan</dc:creator>
    <dc:date>2015-01-28T04:13:41Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1135312">
    <title>[WSS17] Measurement and Visualization of Energy production  &amp;#034;Solar Heaters&amp;#034;</title>
    <link>https://community.wolfram.com/groups/-/m/t/1135312</link>
    <description>In this project we measure the energy produced by a solar Heater; we use a microcontroller, three temperature sensors and a flow sensor.&#xD;
The microcontroller made the calculations for the energy integration and the calculation of volume of water consumed. We send this data to datadrop, for its manipulation and visualization.&#xD;
&#xD;
    datos2 = Dataset[Databin[&amp;#034;mCC3DAXt&amp;#034;]];&#xD;
    data = datos2[&#xD;
        All, {&amp;#034;tempTank&amp;#034; -&amp;gt; N[Quantity[#tempTank/10, &amp;#034;DegreesCelsius&amp;#034;]] &amp;amp;,&#xD;
          &amp;#034;tempIn&amp;#034; -&amp;gt; N[Quantity[#tempIn/10, &amp;#034;DegreesCelsius&amp;#034;]] &amp;amp;, &#xD;
         &amp;#034;tempOut&amp;#034; -&amp;gt; N[Quantity[#tempOut/10, &amp;#034;DegreesCelsius&amp;#034;]] &amp;amp;, &#xD;
         &amp;#034;ms&amp;#034; -&amp;gt; Identity[#ms] &amp;amp;, &#xD;
         &amp;#034;Volume&amp;#034; -&amp;gt; N[Quantity[#Volume/100, &amp;#034;liters&amp;#034;]] &amp;amp;, &#xD;
         &amp;#034;Energy&amp;#034; -&amp;gt; N[Quantity[#Energy/100, &amp;#034;Kilojoules&amp;#034;]] &amp;amp;, &#xD;
         &amp;#034;id&amp;#034; -&amp;gt; Identity[#id] &amp;amp;, &amp;#034;Timestamp&amp;#034; -&amp;gt; Identity[#Timestamp] &amp;amp;}][&#xD;
       All, Association];&#xD;
    dataSort = data[Reverse, Reverse]&#xD;
&#xD;
We totalize variables such as energy and volume of water consumed during the life of the Arduino. So we initialize all the variables we need to show on the sketch.&#xD;
&#xD;
&#xD;
    fVol[n_] := n/100&#xD;
    ftemp[n_] := n/10&#xD;
    fCel[n_] := N[Quantity[n, &amp;#034;DegreesCelsius&amp;#034;]]&#xD;
    fVol1[n_] := N[Quantity[n, &amp;#034;Liters&amp;#034;]]&#xD;
    fEngy[n_] := N[Quantity[n, &amp;#034;Kilojoules&amp;#034;]]&#xD;
    datos3 = datos2[All,&#xD;
      {&#xD;
       &amp;#034;tempTank&amp;#034; -&amp;gt; ftemp,&#xD;
       &amp;#034;tempIn&amp;#034; -&amp;gt; ftemp,&#xD;
       &amp;#034;tempOut&amp;#034; -&amp;gt; ftemp,&#xD;
       &amp;#034;Volume&amp;#034; -&amp;gt; fVol,&#xD;
       &amp;#034;Energy&amp;#034; -&amp;gt; fVol&#xD;
       }&#xD;
      ]&#xD;
    datos4 = datos3[All, {&#xD;
       &amp;#034;tempTank&amp;#034; -&amp;gt; fCel,&#xD;
       &amp;#034;tempIn&amp;#034; -&amp;gt; fCel,&#xD;
       &amp;#034;tempOut&amp;#034; -&amp;gt; fCel,&#xD;
       &amp;#034;Volume&amp;#034; -&amp;gt; fVol1,&#xD;
       &amp;#034;Energy&amp;#034; -&amp;gt; fEngy&#xD;
       }&#xD;
      ]&#xD;
    es = TimeSeries[Databin[&amp;#034;mCC3DAXt&amp;#034;]];&#xD;
    time = DateObject /@ Flatten[es[[1]][[2, 2]]];&#xD;
    en1 = fVol /@ Flatten[es[[1]][[2, 1]]];&#xD;
    en2 = fEngy /@ en1;&#xD;
    tsEngy = TimeSeries[en2, {time}];&#xD;
    vol1 = fVol /@ Flatten[es[[7]][[2, 1]]];&#xD;
    vol2 = fVol1 /@ vol1;&#xD;
    tsVol = TimeSeries[vol2, {time}];&#xD;
    temptank = ftemp /@ Flatten[es[[6]][[2, 1]]];&#xD;
    temptank1 = fCel /@ temptank;&#xD;
    tstempTank = TimeSeries[temptank1, {time}];&#xD;
    tempIn = ftemp /@ Flatten[es[[4]][[2, 1]]];&#xD;
    tempIn1 = fCel /@ tempIn;&#xD;
    tstempIn = TimeSeries[tempIn1, {time}];&#xD;
    tempOut = ftemp /@ Flatten[es[[5]][[2, 1]]];&#xD;
    tempOut1 = fCel /@ tempOut;&#xD;
    tstempOut = TimeSeries[tempOut1, {time}];&#xD;
    totalVolume1 = Total[vol2];&#xD;
    totalEnergy1 = Total[en2];&#xD;
&#xD;
Including the starting time of data and the end time.&#xD;
&#xD;
    lastday = DateList[ Last[Flatten[tstempTank[[2, 2]]]]][[3]]&#xD;
    firstday = DateList[ First[Flatten[tstempTank[[2, 2]]]]][[3]];&#xD;
    firstmonth = DateList[ First[Flatten[tstempTank[[2, 2]]]]][[2]];&#xD;
    lastmonth = DateList[ Last[Flatten[tstempTank[[2, 2]]]]][[2]];&#xD;
    dates = tstempTank[&amp;#034;Dates&amp;#034;];&#xD;
&#xD;
So at the end we can visualize the data on a dice Interface.&#xD;
&#xD;
    Manipulate[&#xD;
     DynamicModule[{firstPage, stadistics},&#xD;
      firstPage = Show[GraphicsGrid[{&#xD;
          {AngularGauge[totalVolume1, {0, 3000}, &#xD;
            ScaleOrigin -&amp;gt; {6 Pi/5, -Pi/5}, PlotTheme -&amp;gt; &amp;#034;Business&amp;#034;, &#xD;
            GaugeLabels -&amp;gt; &amp;#034;Value&amp;#034;, PlotLabel -&amp;gt; &amp;#034;Volume L&amp;#034;, &#xD;
            ImageSize -&amp;gt; 300],&#xD;
             Animate[&#xD;
            Graphics3D[{Red, &#xD;
              Rotate[First@PolyhedronData[&amp;#034;Spikey&amp;#034;], &#xD;
               p*2 \[Pi], {1, 1, 1}]},&#xD;
             Boxed -&amp;gt; False, AspectRatio -&amp;gt; 1, ImageSize -&amp;gt; Medium],&#xD;
            {p, 0, Infinity}, Paneled -&amp;gt; False,&#xD;
            AnimationRunning -&amp;gt; False&#xD;
            ]&#xD;
           ,&#xD;
           Row@{ThermometerGauge[Last[tempIn1], {0, 120}, &#xD;
              PlotLabel -&amp;gt; &amp;#034;Temperature In&amp;#034;, TargetUnits -&amp;gt; &amp;#034;Celsius&amp;#034;, &#xD;
              GaugeLabels -&amp;gt; Full, PlotTheme -&amp;gt; &amp;#034;Marketing&amp;#034;, &#xD;
              ImageSize -&amp;gt; {100, 300}],&#xD;
             ThermometerGauge[Last[tempOut1], {0, 120}, &#xD;
              PlotLabel -&amp;gt; &amp;#034;Temperature Out&amp;#034;, TargetUnits -&amp;gt; &amp;#034;Celsius&amp;#034;, &#xD;
              GaugeLabels -&amp;gt; Full, PlotTheme -&amp;gt; &amp;#034;Marketing&amp;#034;, &#xD;
              ImageSize -&amp;gt; {100, 300}]}},&#xD;
          {AngularGauge[totalEnergy1, {0, 5000}, &#xD;
            ScaleOrigin -&amp;gt; {6 Pi/5, -Pi/5}, PlotTheme -&amp;gt; &amp;#034;Business&amp;#034;, &#xD;
            GaugeLabels -&amp;gt; &amp;#034;Value&amp;#034;, PlotLabel -&amp;gt; &amp;#034;Energy kJ&amp;#034;, &#xD;
            ImageSize -&amp;gt; 300],&#xD;
           SpanFromAbove,&#xD;
           ThermometerGauge[Last[temptank1], {0, 120}, &#xD;
            PlotLabel -&amp;gt; &amp;#034;Tank Temperature&amp;#034;, TargetUnits -&amp;gt; &amp;#034;Celsius&amp;#034;, &#xD;
            GaugeLabels -&amp;gt; Full, PlotTheme -&amp;gt; &amp;#034;Marketing&amp;#034;, &#xD;
            ImageSize -&amp;gt; {200, 300}]}}&#xD;
         ,&#xD;
         Frame -&amp;gt; False,&#xD;
         Alignment -&amp;gt; Center,&#xD;
         Background -&amp;gt; Transparent,&#xD;
         BaseStyle -&amp;gt; {FontColor -&amp;gt; GrayLevel[0.6], FontFamily -&amp;gt; &amp;#034;Times&amp;#034;,&#xD;
            30}&#xD;
         ]];&#xD;
      &#xD;
      stadistics = &#xD;
       Show[GraphicsGrid[{{relojes, SpanFromLeft, SpanFromLeft},&#xD;
          {With[{dataAssoc = GroupBy[dates, #[&amp;#034;Month&amp;#034;] &amp;amp;]}, &#xD;
            Manipulate[Manipulate[&#xD;
                 DateListPlot[&#xD;
               TimeSeriesWindow[tsEngy, &#xD;
                DateObject[{2017, month, day}, &amp;#034;Day&amp;#034;]],&#xD;
               PlotTheme -&amp;gt; &amp;#034;Web&amp;#034;,&#xD;
               Joined -&amp;gt; False,&#xD;
               Filling -&amp;gt; Axis,&#xD;
               ImageSize -&amp;gt; 200,&#xD;
               PlotRange -&amp;gt; All,&#xD;
               PlotLabel -&amp;gt; DateObject[{2017, month, day}, &amp;#034;Day&amp;#034;]&#xD;
               &#xD;
               ], &#xD;
              Style[&amp;#034;Energy Produced&amp;#034;, 25, Bold, FontFamily -&amp;gt; &amp;#034;Times&amp;#034;, &#xD;
               TextAlignment -&amp;gt; Center],&#xD;
              {day, &#xD;
               Sequence @@ (MinMax[#[&amp;#034;Day&amp;#034;] &amp;amp; /@ (dataAssoc[month])]), 1},&#xD;
               Paneled -&amp;gt; False],&#xD;
             {{month, lastmonth}, &#xD;
              Sequence @@ &#xD;
               MinMax[Keys[MinMax[#[&amp;#034;Day&amp;#034;] &amp;amp; /@ #] &amp;amp; /@ dataAssoc]], 1}&#xD;
             &#xD;
             , SynchronousUpdating -&amp;gt; True, Paneled -&amp;gt; False]],&#xD;
           &#xD;
           With[{dataAssoc = GroupBy[dates, #[&amp;#034;Month&amp;#034;] &amp;amp;]}, &#xD;
            Manipulate[Manipulate[&#xD;
              &#xD;
              DateListPlot[&#xD;
               TimeSeriesWindow[tstempTank, &#xD;
                DateObject[{2017, month, day}, &amp;#034;Day&amp;#034;]],&#xD;
               PlotTheme -&amp;gt; &amp;#034;Web&amp;#034;,&#xD;
               Joined -&amp;gt; False,&#xD;
               Filling -&amp;gt; Axis,&#xD;
               ImageSize -&amp;gt; 200,&#xD;
               PlotRange -&amp;gt; All,&#xD;
               PlotLabel -&amp;gt; DateObject[{2017, month, day}, &amp;#034;Day&amp;#034;]&#xD;
               &#xD;
               ], &#xD;
              &#xD;
              Style[&amp;#034;Tank Temperature&amp;#034;, 25, Bold, FontFamily -&amp;gt; &amp;#034;Times&amp;#034;, &#xD;
               TextAlignment -&amp;gt; Center],&#xD;
              {day, &#xD;
               Sequence @@ (MinMax[#[&amp;#034;Day&amp;#034;] &amp;amp; /@ (dataAssoc[month])]), 1},&#xD;
               Paneled -&amp;gt; False],&#xD;
             {{month, lastmonth}, &#xD;
              Sequence @@ &#xD;
               MinMax[Keys[MinMax[#[&amp;#034;Day&amp;#034;] &amp;amp; /@ #] &amp;amp; /@ dataAssoc]], 1},&#xD;
             &#xD;
             SynchronousUpdating -&amp;gt; True, Paneled -&amp;gt; False]],&#xD;
           &#xD;
           With[{dataAssoc = GroupBy[dates, #[&amp;#034;Month&amp;#034;] &amp;amp;]}, &#xD;
            Manipulate[Manipulate[&#xD;
              &#xD;
              DateListPlot[&#xD;
               TimeSeriesWindow[tsVol, &#xD;
                DateObject[{2017, month, day}, &amp;#034;Day&amp;#034;]],&#xD;
               PlotTheme -&amp;gt; &amp;#034;Web&amp;#034;,&#xD;
               Joined -&amp;gt; False,&#xD;
               Filling -&amp;gt; Axis,&#xD;
               ImageSize -&amp;gt; 200,&#xD;
               PlotRange -&amp;gt; All,&#xD;
               PlotLabel -&amp;gt; DateObject[{2017, month, day}, &amp;#034;Day&amp;#034;]&#xD;
               &#xD;
               ], &#xD;
              Style[&amp;#034;Hot Water Consumed &amp;#034;, 25, Bold, &#xD;
               FontFamily -&amp;gt; &amp;#034;Times&amp;#034;, TextAlignment -&amp;gt; Center],&#xD;
              {day, &#xD;
               Sequence @@ (MinMax[#[&amp;#034;Day&amp;#034;] &amp;amp; /@ (dataAssoc[month])]), 1},&#xD;
               Paneled -&amp;gt; False],&#xD;
             {{month, lastmonth}, &#xD;
              Sequence @@ &#xD;
               MinMax[Keys[MinMax[#[&amp;#034;Day&amp;#034;] &amp;amp; /@ #] &amp;amp; /@ dataAssoc]], 1},&#xD;
             &#xD;
             SynchronousUpdating -&amp;gt; True, Paneled -&amp;gt; False]]}},&#xD;
         ItemAspectRatio -&amp;gt; 1 ,&#xD;
         ImageSize -&amp;gt; 1000,&#xD;
         Frame -&amp;gt; False,&#xD;
         Alignment -&amp;gt; Center,&#xD;
         Background -&amp;gt; Transparent,&#xD;
         BaseStyle -&amp;gt; {FontColor -&amp;gt; Black, FontFamily -&amp;gt; &amp;#034;Times&amp;#034;, 30}]&#xD;
        &#xD;
        ];&#xD;
      Show[Switch[vizualization, 1, firstPage, 2, stadistics], &#xD;
       ImageSize -&amp;gt; {1000, 700}]&#xD;
      ],&#xD;
     Control[{{vizualization, 1, &amp;#034;&amp;#034;}, {1 -&amp;gt; &amp;#034;Parameters&amp;#034;, &#xD;
        2 -&amp;gt; &amp;#034;Statistics&amp;#034;}, Setter}],&#xD;
     PaneSelector[{&#xD;
       1 -&amp;gt; Column@{Spacer@2, &#xD;
          Style[&amp;#034;Measurement and Visualization of Energy production  \&#xD;
    \&amp;#034;Solar Heaters\&amp;#034;&amp;#034;, 40, Bold, FontFamily -&amp;gt; Times, &#xD;
           TextAlignment -&amp;gt; Center]},&#xD;
       2 -&amp;gt; Column@{Spacer@2, &#xD;
          Style[&amp;#034;Statistics&amp;#034;, 40, Bold, FontFamily -&amp;gt; Times, &#xD;
           TextAlignment -&amp;gt; Center]}},&#xD;
      Dynamic@vizualization],&#xD;
     SaveDefinitions -&amp;gt; True,&#xD;
     Paneled -&amp;gt; False]&#xD;
&#xD;
![Visualization][1]&#xD;
&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Capturadepantalla2017-07-04ala%28s%2921.28.03.png&amp;amp;userId=1017357&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Capturadepantalla2017-07-04ala%28s%2921.28.33.png&amp;amp;userId=1017357</description>
    <dc:creator>Ruben Garcia</dc:creator>
    <dc:date>2017-07-05T01:33:20Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/984688">
    <title>Define functions for variables with units?</title>
    <link>https://community.wolfram.com/groups/-/m/t/984688</link>
    <description>Units are important in engineering and science, so I need to get my students to be religious about using them. I provide answers to homework and exams using Mathematica. Incorporating units in simple computations is relatively easy, but I have difficulty in using units with functions. For example how do I define a function &#xD;
&#xD;
    d[t_]:=10*t^2 + 5*t+25&#xD;
&#xD;
where the units of t are seconds? In subsequent calls of the function, do I need to use the Quantity notation for every specific numeric value of t?</description>
    <dc:creator>Orest Gogosha</dc:creator>
    <dc:date>2016-12-21T21:01:23Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1731427">
    <title>[WSS19] Investment Strategies: Functional Weighted Choice Method</title>
    <link>https://community.wolfram.com/groups/-/m/t/1731427</link>
    <description>![pic03][4]&#xD;
&#xD;
Disclaimer&#xD;
--------&#xD;
This computational notebook is not to be sold or exchanged for either monetary or non-monetary gains in anyway. The notebook is not to be modified without prior written consent from the author. ?The calculation only serves as an additional reference for equity investors and investment advisors. Any liability, including any liability for negligence, for any loss or damage arising from reliance on this computational notebook, is expressly excluded. Under no circumstance shall the author of this computational notebook or Wolfram Research be held responsible for third-party&amp;#039;s application, investment recommendation, or other usage originating from this computational notebook.&#xD;
&#xD;
I. Abstract&#xD;
--------&#xD;
A quantitative model was derived to analyze common collections of investment tactics. The model was designed with flexibility: it can choose and weight the stocks into a portfolio of any size, based on any analytic expression of the stocks&amp;#039; financial characteristics, allowing both whole and fractional shares, with an option for additional investment. Using the model, several common investment strategies were investigated: chosen and weighted by price; chosen by price, equally weighted; chosen by volume, weighted by market capitalization; chosen and weighted by market capitalization. The model shows that a less frequently adjusted portfolio seems to perform better, supporting the buy-and-hold tactic. The model also indicate that the size of the portfolio, does not exert a strong effect on the strategy&amp;#039;s overall performance.&#xD;
&#xD;
II. Introduction&#xD;
--------&#xD;
Equity investing remains a significant vehicle to preserve and generate wealth. Owing to the advances in technology and computational instruments, as well as the readily available financial data, strategical equity investing has become more technically accessible. Yet, apart from large financial institutions (such as hedge-funds and investment banks), the analyzing tools for investment strategies are not readily available to most individual investors - and even when the tools are available, the analysis are often basic and limited. Hence, a mathematically robust, versatile tool for investment strategy would enable more people to participate in investing, to make better-informed choice, which may narrows the standard of living gap between different social classes.&#xD;
&#xD;
Here, a computational model was derived and freely distributed to help quantifying the most common collection of investment strategies: the model aims to quantify the portfolio&amp;#039;s performance, in which stocks are chosen and weighted based on certain criteria. The model consists of two distinct parts: the gathering of historical data/financial information, and the construction of the portfolios - back-testing on historical data for theoretical performance (transactional fees and other necessary costs are not included in the model).&#xD;
&#xD;
III. Data Gathering&#xD;
--------&#xD;
&#xD;
    ClearAll[&amp;#034;Global`*&amp;#034;];&#xD;
    SetDirectory[NotebookDirectory[]];&#xD;
&#xD;
First, a collection of stocks is specified: this collection will serve as the &amp;#034;set of all stocks&amp;#034;, from which the portfolios will be constructed. For the purpose of constructing and testing a computational model, the collection is chosen to be SP500: all the stocks that are listed on the Standard and Poor 500 Index (^SPX)&#xD;
&#xD;
    listStock = EntityList[EntityClass[&amp;#034;Financial&amp;#034;, &amp;#034;SP500&amp;#034;]];&#xD;
    DumpSave[&amp;#034;listStock.MX&amp;#034;, listStock];&#xD;
&#xD;
This specified &amp;#034;set of all stocks&amp;#034; SP500 is then associated with multiple other financial properties: price, option2, option3, option4, option5, option6. Price is always included, since stock price is necessary to quantify an investment strategy&amp;#039;s performance. The other options are chosen from the following list, so that they result in timeseries (measurements over time) of the properties (as currently supported by Wolfram Mathematica kernel, 2019-07-10): {&amp;#034;Change&amp;#034;, &amp;#034;Close&amp;#034;, &amp;#034;CumulativeFractionalChange&amp;#034;, &amp;#034;Dividend&amp;#034;, &amp;#034;DividendPerShare&amp;#034;, &amp;#034;Last&amp;#034;, &amp;#034;MarketCap&amp;#034;, &amp;#034;Open&amp;#034;, &amp;#034;Price&amp;#034;, &amp;#034;RawVolume&amp;#034;, &amp;#034;Return&amp;#034;, &amp;#034;Volume&amp;#034;}. If an option is not used, that option must be specified as &amp;#034;None&amp;#034;.&#xD;
&#xD;
The financial properties for the &amp;#034;set of all stocks&amp;#034; are collected with one call of FinanciaData[], in order to minimize the downloading time. Yet, because of the sheer size of the timeseries: all daily data points of several properties of all stocks since the stocks&amp;#039; inception, the financial properties may take as much as two hours to be procured (the Boolean variable run is used to prevent inadvertently overwriting the obtained data file - it needs to be changed to True in order to execute the codes in this section).&#xD;
&#xD;
    option2 = &amp;#034;MarketCap&amp;#034;;&#xD;
    option3 = &amp;#034;Volume&amp;#034;;&#xD;
    option4 = &amp;#034;Close&amp;#034;;&#xD;
    option5 = &amp;#034;Open&amp;#034;;&#xD;
    option6 = &amp;#034;None&amp;#034;;&#xD;
    listOptions = &#xD;
      DeleteCases[{option2, option3, option4, option5, option6}, &amp;#034;None&amp;#034;];&#xD;
    DumpSave[&amp;#034;listOptions.MX&amp;#034;, listOptions];&#xD;
    &#xD;
    run = False;&#xD;
    If[run == True, &#xD;
      listStockPropRaw = &#xD;
       FinancialData[listStock, Prepend[listOptions, &amp;#034;Price&amp;#034;], All]];&#xD;
&#xD;
The portfolios will be compared against a benchmark to assess their performance. This benchmark is chosen to be the Standard and Poor 500 Index (^SPX): the data is stored in sp500All variable.&#xD;
&#xD;
    sp500All = FinancialData[&amp;#034;^SPX&amp;#034;, All];&#xD;
    DumpSave[&amp;#034;sp500All.MX&amp;#034;, sp500All];&#xD;
&#xD;
Once all the financial properties are (finally) obtained, the timeseries are changed into interpolation order of 0, which means missing/interval measurements will be identical to its immediately previous measurement, effectively describing a step function (instead of interpolating the interval measurement from both its immediate previous data point and its next data point - i.e. using future data to make a present decision). This step is crucial for back-testing, especially with quarterly (every three months) financial data such as dividend, total asset, total liability, EBITDA (earnings before interest, tax, depreciation and amortization), etc.&#xD;
&#xD;
(At the moment, Wolfram Research has plan to incorporate EntityValue[] of entity &amp;#034;Company&amp;#034; into the FinancialData[] function, so that by querying a stock, the associated company&amp;#039;s financial and accounting information can be obtained.)&#xD;
&#xD;
    If[run == True,&#xD;
     listStockProp = &#xD;
      Replace[listStockPropRaw, &#xD;
       List[&amp;#034;Interpolation&amp;#034;, Rule[InterpolationOrder, 1]] -&amp;gt; &#xD;
        List[&amp;#034;Interpolation&amp;#034;, Rule[InterpolationOrder, 0]], {5}];&#xD;
     DumpSave[&amp;#034;listStockProp.MX&amp;#034;, listStockProp];&#xD;
     ]&#xD;
&#xD;
The SP500 stocks&amp;#039;s name and financial properties are combined into one variable: masterThread, with its definition saved into &amp;#034;masterThreadGeneral.MX&amp;#034;. The variable masterThread is ascertained with its length and an excerpt of its contents.&#xD;
&#xD;
    If[run == True,&#xD;
     CompoundExpression[&#xD;
      masterThreadNotIndexed =&#xD;
       DeleteMissing[&#xD;
        Transpose[Prepend[Transpose[listStockProp], listStock]],&#xD;
        1, 3];&#xD;
      &#xD;
      masterThread = &#xD;
       Transpose[&#xD;
        Prepend[Transpose[masterThreadNotIndexed], &#xD;
         Range[Length[masterThreadNotIndexed]]]];&#xD;
      DumpSave[&amp;#034;masterThreadGeneral.MX&amp;#034;, masterThread];&#xD;
      &#xD;
      masterThread // Length&#xD;
          RandomSample[masterThread, 5] // TableForm // Print&#xD;
      ]]&#xD;
&#xD;
For the sole purpose of constructing the computational model, a smaller set of 64 randomly selected stocks from SP500 are obtained (since making a portfolio by sorting the whole 505 stocks in the SP500 set would take a bit longer - which is unnecessary at this stage).&#xD;
&#xD;
    If[run == True,&#xD;
     CompoundExpression[&#xD;
      ClearAll[masterThread];&#xD;
      masterThreadNotIndexedSample = RandomSample[&#xD;
        DeleteMissing[&#xD;
         Transpose[Prepend[Transpose[listStockProp], listStock]],&#xD;
         1, 3], 64];&#xD;
      &#xD;
      masterThread = &#xD;
       Transpose[&#xD;
        Prepend[Transpose[masterThreadNotIndexedSample], &#xD;
         Range[Length[masterThreadNotIndexedSample]]]];&#xD;
      DumpSave[&amp;#034;masterThreadSample64.MX&amp;#034;, masterThread];&#xD;
      &#xD;
      masterThread // Length&#xD;
         RandomSample[masterThread, 5] // TableForm // Print&#xD;
      ]]&#xD;
&#xD;
IV. Constructing the computational model&#xD;
--------&#xD;
First, the previously constructed listOptions, sp500All, and the masterThread variables are reloaded into a clean Mathematica kernel.&#xD;
&#xD;
    ClearAll[&amp;#034;Global`*&amp;#034;];&#xD;
    SetDirectory[NotebookDirectory[]];&#xD;
    Off[InterpolatingFunction::dmval];&#xD;
    Off[EntityValue::conopen];&#xD;
    &#xD;
    Get[&amp;#034;listOptions.MX&amp;#034;];&#xD;
    Get[&amp;#034;sp500All.MX&amp;#034;];&#xD;
    Get[&amp;#034;masterThreadGeneral.MX&amp;#034;];&#xD;
&#xD;
The inputs for the computational model are specified:&#xD;
&#xD;
- timePeriod denotes the portfolio&amp;#039;s frequency of adjustment in whole number of days: timePeriod = n means that the portfolio is updated/adjusted every n days.&#xD;
&#xD;
- sizePortfolio denotes the portfolio&amp;#039;s size - the pre-specified number of stocks the portfolio contains. Obviously, the portfolio size must be smaller than the number of stocks in masterThread.&#xD;
&#xD;
- taxRate takes into account the rate of tax on capital gain. Here, the tax is set at 40% for any capital gain each time the portfolio is rebalanced, and immediately deducted. This setup is much more restrictive than the personal income tax schedule in the U.S.: rate depending on personal income (maximum 37%, 2019), calculated for the whole year, and not due until April of the following year.&#xD;
	&#xD;
- initialInvest specifies the initial amount of money invested in the portfolio.&#xD;
&#xD;
- dailyInvest specifies the additional daily amount of money invested in the portfolio. Each time the portfolio is rebalanced, an amount of dailyInvest*timePeriod will be added into the portfolio.&#xD;
	&#xD;
- optionWholeShare specified whether only whole numbers (positive integers) of stock share are allowed, or fractional shares are also possible, as some trading platforms permit whole share only. Variable optionWholeShare accepts only Boolean values True or False.&#xD;
	&#xD;
- beginDate denotes the first date of the investigated time window.&#xD;
&#xD;
- endDate denotes the last date of the investigated time window.&#xD;
	&#xD;
- funcSort[] determines how the stocks in masterThread (the &amp;#034;set of all stocks&amp;#034;) at one specific instant of time are sorted for selection, from largest to smallest. Function funcSort accepts any analytic expression of x1, x2, x3, x4, x5,..., corresponding to the financial properties &amp;#034;Price&amp;#034;, option2, option3, option4, option5,...&#xD;
&#xD;
- optionTake, which is linked to funcTake[] on the following paragraph, specified how the stocks are collected into a portfolio from the sorted  masterThread (using funcSort). Variable optionTake is designed to accept only three designation: &amp;#034;high&amp;#034;, meaning the largest stocks are taken (with respect to their metrics obtained from funcSort); &amp;#034;low&amp;#034;, meaning the smallest stocks are taken; and mid&amp;#034;, meaning the middle stocks are taken.&#xD;
&#xD;
- funcWeight[] determines how the selected stocks in the portfolio are weighted for investment. Function funcWeight accepts any analytic expression of x1, x2, x3, x4, x5,..., corresponding to the financial properties &amp;#034;Price&amp;#034;, option2, option3, option4, option5,... To use funcWeight, optionEqualWeight must be False.&#xD;
&#xD;
- optionEqualWeight denotes whether to use funcWeight[], or to assign equal weight to all selected stocks in the portfolio. Variable optionEqualWeight accepts only Boolean values True or False.&#xD;
	&#xD;
- Function funcTake[], mentioned earlier with variable optionTake, is defined to execute the input given to optionTake.&#xD;
- Variable sp500Ratio stores the relative value of the Standard and Poor 500 Index (^SPX) since the first date of the investigated time window - of which the portfolio performance is compared against.&#xD;
&#xD;
        timePeriod = 56;&#xD;
        sizePortfolio = 10;&#xD;
        taxRate = 0.4;&#xD;
        initialInvest = 100.00;&#xD;
        dailyInvest = 0.00;&#xD;
        optionWholeShare = False;&#xD;
        &#xD;
        beginDate = DateObject[&amp;#034;2004-07-01&amp;#034;];&#xD;
        endDate = DateObject[&amp;#034;2019-07-01&amp;#034;];&#xD;
        &#xD;
        funcSort[x1_, x2_, x3_, x4_, x5_] := &#xD;
          x2/10^6 + x3/10^3 + Sqrt[(Sin[Log[x2 + 1]])^2 + (ArcTan[x3])^2];&#xD;
        &#xD;
        optionTake = &amp;#034;low&amp;#034;; (*high mid low*)&#xD;
        &#xD;
        funcWeight[x1_, x2_, x3_, x4_, x5_] := (&#xD;
           Abs[2 (x5 - x4)] + Log[x5 + x4 + 1]^-1)/(x5 + x4) x1;&#xD;
        &#xD;
        optionEqualWeight = False;&#xD;
        &#xD;
        initialFunc[] := Module[{},&#xD;
           CompoundExpression[&#xD;
            portValue[beginDate] = Quantity[initialInvest, &amp;#034;USDollars&amp;#034;];&#xD;
            investAmount = Quantity[dailyInvest, &amp;#034;USDollars&amp;#034;]*timePeriod;&#xD;
            &#xD;
            funcTake[sortedListVar_, sizePortfolioVar_] := Which[&#xD;
              optionTake == &amp;#034;high&amp;#034;, Take[sortedListVar, sizePortfolioVar],&#xD;
              optionTake == &amp;#034;mid&amp;#034;, &#xD;
              Take[sortedListVar, {Floor[(&#xD;
                 Length[sortedListVar] - sizePortfolioVar)/2], &#xD;
                Floor[(Length[sortedListVar] + sizePortfolioVar)/2] - 1}],&#xD;
              optionTake == &amp;#034;low&amp;#034;, Take[sortedListVar, -sizePortfolioVar]&#xD;
              ];&#xD;
            &#xD;
            sp500 = &#xD;
             TimeSeriesWindow[sp500All, {beginDate, endDate}, &#xD;
              IncludeWindowTimes -&amp;gt; True, &#xD;
              ResamplingMethod -&amp;gt; {&amp;#034;Interpolation&amp;#034;, InterpolationOrder -&amp;gt; 0}];&#xD;
            sp500Ratio = sp500/QuantityMagnitude[sp500[beginDate]];&#xD;
            ]];&#xD;
&#xD;
The function callFuncBody[] constitutes the essence of the model: it determines the portfolio&amp;#039;s value at each instant of adjustment.&#xD;
&#xD;
First, the function chooses the stocks to be included in the portfolio along with their weight-by-investment-amount: by sorting with funcSort, choosing with optionTake/funcTake, and weighting with funcWeight, on the pre-defined stocks&amp;#039; properties, from the previous day (to assure that all properties are available, that future information is not used to make present decision).&#xD;
Then, the function distributes the current portfolio value to the chosen list of stocks , from which it registers the number of shares of the chosen stocks.&#xD;
If only whole share number is allowed, the function ensures that portfolio&amp;#039;s value remains sufficient to purchase at least one share of each stock chosen, by mean of additional investment.&#xD;
&#xD;
At the next date of adjustment, the function uses the previous number of shares and new stock prices to compute the new portfolio value - after any applicable tax and additional investment.&#xD;
This new portfolio value is hence used to derive the new number of shares, etc.&#xD;
The function repeats the process until it spans over the whole pre-specified time window. The portfolio value is capped at 100 times the total amount of investment.&#xD;
&#xD;
The function callFunc[] imposes necessary conditions on callFuncBody[]: the model will only evaluates with proper inputs. More importantly, the function callFunc[] incorporates the model&amp;#039;s downstream processing steps.&#xD;
&#xD;
    (*callFuncBody[]*)&#xD;
    callFuncBody[] := &#xD;
      Module[{threadPrevious = {}, indexPrevious = {}, threadAtTime, &#xD;
        threadAtTimeMinus1, newPriceList, threadAtTimeAppend, sortedList, &#xD;
        listChosen, t, tMinus1, tprevious, newPortValue, &#xD;
        portValuePrevious, fractionalAmount, priceListPrevious, &#xD;
        differenceValue},&#xD;
       initialFunc[];&#xD;
       listDate = {};&#xD;
       TimeConstrained[&#xD;
        For[t = beginDate, t &amp;lt;= endDate, t = DatePlus[t, timePeriod],&#xD;
         threadAtTime = &#xD;
          MapAt[#[t] &amp;amp;, &#xD;
           masterThread, {All, Table[n, {n, 3, Length[listOptions] + 3}]}];&#xD;
         tMinus1 = DatePlus[t, -1];&#xD;
         threadAtTimeMinus1 = &#xD;
          MapAt[#[tMinus1] &amp;amp;, &#xD;
           masterThread, {All, Table[n, {n, 3, Length[listOptions] + 3}]}];&#xD;
         &#xD;
         If[And[&#xD;
           FreeQ[QuantityMagnitude[threadAtTime], _Missing, 2],&#xD;
           FreeQ[QuantityMagnitude[threadAtTimeMinus1], _Missing, 2],&#xD;
           threadAtTime != threadPrevious],&#xD;
          &#xD;
          CompoundExpression[&#xD;
           &#xD;
           If[indexPrevious != {},&#xD;
            CompoundExpression[&#xD;
             newPriceList = &#xD;
              Select[threadAtTime, MemberQ[indexPrevious, #[[1]]] &amp;amp;][[All,&#xD;
                3]];&#xD;
             differenceValue = &#xD;
              Dot[newPriceList - priceListPrevious, &#xD;
               listShareNumber[tPrevious]];&#xD;
             portValue[t] = If[QuantityMagnitude[differenceValue] &amp;gt; 0,&#xD;
               &#xD;
               Min[100 (investAmount*&#xD;
                    QuantityMagnitude[&#xD;
                     DateDifference[beginDate, endDate]] + (portValue[&#xD;
                      beginDate] + addFund[beginDate])), &#xD;
                portValuePrevious + (1 - taxRate) differenceValue + &#xD;
                 investAmount],&#xD;
               &#xD;
               Min[100 (investAmount*&#xD;
                    QuantityMagnitude[&#xD;
                     DateDifference[beginDate, endDate]] + (portValue[&#xD;
                      beginDate] + addFund[beginDate])), &#xD;
                portValuePrevious + differenceValue + investAmount]&#xD;
               ](*IF*);&#xD;
             ](*CompoundExpression*)](*IF*);&#xD;
           &#xD;
           sortList = funcSort[x1, x2, x3, x4, x5] /. Table[&#xD;
              Evaluate[Symbol[StringJoin[&amp;#034;x&amp;#034;, ToString[n - 2]]]] -&amp;gt; &#xD;
               QuantityMagnitude[threadAtTimeMinus1[[All, n]]],&#xD;
              {n, 3, Length[listOptions] + 3}];&#xD;
           &#xD;
           (*{x1\[Rule]QuantityMagnitude[threadAtTimeMinus1[[All,3]]],&#xD;
           x2\[Rule]QuantityMagnitude[threadAtTimeMinus1[[All,4]]],&#xD;
           x3\[Rule]QuantityMagnitude[threadAtTimeMinus1[[All,5]]],&#xD;
           x4\[Rule]QuantityMagnitude[threadAtTimeMinus1[[All,6]]],&#xD;
           x5\[Rule]QuantityMagnitude[threadAtTimeMinus1[[All,7]]]};*)&#xD;
           &#xD;
           weightList = If[optionEqualWeight == False,&#xD;
             funcWeight[x1, x2, x3, x4, x5] /. Table[&#xD;
               Evaluate[Symbol[StringJoin[&amp;#034;x&amp;#034;, ToString[n - 2]]]] -&amp;gt; &#xD;
                QuantityMagnitude[threadAtTimeMinus1[[All, n]]],&#xD;
               {n, 3, Length[listOptions] + 3}],&#xD;
             ConstantArray[1/Length[masterThread], Length[masterThread]]&#xD;
             ];&#xD;
           &#xD;
           threadAtTimeAppend = &#xD;
            Transpose[&#xD;
             Join[Transpose[threadAtTime], {sortList}, {weightList}]];&#xD;
           sortedList = Sort[threadAtTimeAppend, #1[[-2]] &amp;gt; #2[[-2]] &amp;amp;];&#xD;
           listChosen = &#xD;
            Sort[funcTake[sortedList, sizePortfolio], #1[[1]] &amp;lt; #2[[1]] &amp;amp;];&#xD;
           &#xD;
           weight = &#xD;
            If[And[optionEqualWeight == False, &#xD;
              0 &amp;lt; QuantityMagnitude[Min[weightList]], &#xD;
              QuantityMagnitude[Max[weightList]] &amp;lt; \[Infinity]],&#xD;
             listChosen[[All, -1]]/Total[listChosen[[All, -1]]],&#xD;
             ConstantArray[1/sizePortfolio, sizePortfolio]&#xD;
             ];&#xD;
           &#xD;
           If[optionWholeShare == True,&#xD;
            CompoundExpression[&#xD;
             If[&#xD;
              portValue[t] &amp;lt; &#xD;
               Dot[listChosen[[All, 3]], ConstantArray[1, sizePortfolio]],&#xD;
              CompoundExpression[&#xD;
               &#xD;
               addFund[t] = &#xD;
                investAmount + &#xD;
                 Dot[listChosen[[All, 3]], &#xD;
                  ConstantArray[1, sizePortfolio]] - portValue[t];&#xD;
               &#xD;
               portValue[t] = &#xD;
                investAmount + &#xD;
                 Dot[listChosen[[All, 3]], &#xD;
                  ConstantArray[1, sizePortfolio]];&#xD;
               ],&#xD;
              addFund[t] = investAmount];&#xD;
             &#xD;
             listShareNumber[t] = &#xD;
              Floor[weight*portValue[t]/listChosen[[All, 3]]];&#xD;
             ](*CompoundExpression*),&#xD;
            &#xD;
            CompoundExpression[&#xD;
              addFund[t] = investAmount;&#xD;
              &#xD;
              listShareNumber[t] = &#xD;
               weight*portValue[t]/listChosen[[All, 3]];&#xD;
              ](*CompoundExpression*);&#xD;
            ](*If*);&#xD;
           &#xD;
           portAtTime[t] = &#xD;
            Thread[{listChosen[[All, 1]], listChosen[[All, 2]], &#xD;
              listChosen[[All, 3]], listShareNumber[t], &#xD;
              listChosen[[All, -2]], listChosen[[All, -1]]}];&#xD;
           &#xD;
           Do[&#xD;
            shareNo[listChosen[[i, 1]], t] = listShareNumber[t][[i]],&#xD;
            {i, 1, Length[listChosen]}&#xD;
            ];&#xD;
           &#xD;
           Do[&#xD;
            shareNo[n, t] = 0,&#xD;
            {n, &#xD;
             Complement[Range[Length[masterThread]], listChosen[[All, 1]]]}&#xD;
            ];&#xD;
           &#xD;
           AppendTo[listDate, t];&#xD;
           threadPrevious = threadAtTime;&#xD;
           tPrevious = t;&#xD;
           portValuePrevious = portValue[t];&#xD;
           indexPrevious = listChosen[[All, 1]];&#xD;
           priceListPrevious = listChosen[[All, 3]];&#xD;
           &#xD;
           ](*CompoundExpression*),&#xD;
          t = DatePlus[t, -timePeriod + 1];](*If*)&#xD;
         ](*For*),&#xD;
        10*60, Print[&amp;#034;Time Out!&amp;#034;](*TimeConstrained*)];&#xD;
       ](*Module*);&#xD;
    &#xD;
    (*&amp;amp;&amp;amp;&amp;amp;***&amp;amp;&amp;amp;&amp;amp;***&amp;amp;&amp;amp;&amp;amp;***&amp;amp;&amp;amp;&amp;amp;***&amp;amp;&amp;amp;&amp;amp;***&amp;amp;&amp;amp;&amp;amp;***&amp;amp;&amp;amp;&amp;amp;***&amp;amp;&amp;amp;&amp;amp;***&amp;amp;&amp;amp;&amp;amp;***&amp;amp;&amp;amp;&amp;amp;***&amp;amp;&amp;amp;&amp;amp;*)&#xD;
    &#xD;
    (*callFunc[]*)&#xD;
    callFunc[] := If[&#xD;
       And[&#xD;
        Length[masterThread] &amp;gt; sizePortfolio,&#xD;
        IntegerQ[sizePortfolio],&#xD;
        sizePortfolio &amp;gt; 0,&#xD;
        beginDate &amp;lt;= endDate,&#xD;
        IntegerQ[timePeriod],&#xD;
        timePeriod &amp;gt; 0,&#xD;
        MemberQ[{&amp;#034;high&amp;#034;, &amp;#034;mid&amp;#034;, &amp;#034;low&amp;#034;}, optionTake],&#xD;
        BooleanQ[optionEqualWeight],&#xD;
        BooleanQ[optionWholeShare]&#xD;
        ](*And*),&#xD;
       &#xD;
       CompoundExpression[&#xD;
        callFuncBody[];&#xD;
        addFund[beginDate] = portValue[beginDate];&#xD;
        &#xD;
        Do[&#xD;
         shareNumberTimeSeries[n] = &#xD;
          TimeSeries[Table[shareNo[n, t], {t, listDate}], {listDate}, &#xD;
           ResamplingMethod -&amp;gt; {&amp;#034;Interpolation&amp;#034;, InterpolationOrder -&amp;gt; 0}],&#xD;
         {n, 1, Length[masterThread]}&#xD;
         ](*Do*);&#xD;
        &#xD;
        portValueTimeSeries = &#xD;
         TimeSeries[Table[portValue[t], {t, listDate}], {listDate}, &#xD;
          ResamplingMethod -&amp;gt; {&amp;#034;Interpolation&amp;#034;, InterpolationOrder -&amp;gt; 0}];&#xD;
        portValueTimeSeriesRatio = &#xD;
         portValueTimeSeries/portValueTimeSeries[&amp;#034;FirstValue&amp;#034;];&#xD;
        &#xD;
        addFundTimeSeries = &#xD;
         TimeSeries[Table[addFund[t], {t, listDate}], {listDate}, &#xD;
          MissingDataMethod -&amp;gt; {&amp;#034;Constant&amp;#034;, Quantity[0.00, &amp;#034;USDollars&amp;#034;]}, &#xD;
          ResamplingMethod -&amp;gt; {&amp;#034;Constant&amp;#034;, Quantity[0.00, &amp;#034;USDollars&amp;#034;]}];&#xD;
        addFundTimeSeriesRatio = &#xD;
         addFundTimeSeries/portValueTimeSeries[&amp;#034;FirstValue&amp;#034;];&#xD;
        &#xD;
        finalList = &#xD;
         Transpose[&#xD;
          Append[Transpose[masterThread], &#xD;
           Table[shareNumberTimeSeries[n], {n, 1, Length[masterThread]}]]];&#xD;
        &#xD;
        ](*CompoundExpression*),&#xD;
       &#xD;
       Print[&amp;#034;Error: problematic input(s)! Model will not run.&amp;#034;]&#xD;
       ](*If*);&#xD;
&#xD;
Function callFunc[] defines several global variables:&#xD;
&#xD;
- listDate: the list of all the dates at which the portfolio was adjusted.&#xD;
&#xD;
- portAtTime[t]: the component of the portfolio at an instance of time t. The instance of time t must be an element of the list of all date listDate.&#xD;
&#xD;
- shareNumberTimeSeries[n]: the timeseries of the share number in portfolio of the nth stock in masterThread (1 &amp;lt;= n &amp;lt;= Length[masterThread])&#xD;
&#xD;
- portValueTimeSeries: the timeseries of portfolio value.&#xD;
&#xD;
- addFundTimeSeries: the timeseries of additional investment.&#xD;
&#xD;
- finalList: the list of all stocks and their properties, with their share number appended.&#xD;
&#xD;
        callFunc[];&#xD;
        &#xD;
        Hold[&#xD;
          Take[listDate, 6] // TableForm // Print;&#xD;
          Table[{t, portAtTime[t]}, {t, listDate}] // TableForm // Print;&#xD;
          Table[{n, shareNumberTimeSeries[n]}, {n, 1, 6}] // TableForm // &#xD;
           Print;&#xD;
          portValueTimeSeries // Print;&#xD;
          addFundTimeSeries // Print;&#xD;
          Take[finalList, 5] // TableForm // Print;&#xD;
          ];&#xD;
&#xD;
Here is an example of the finalList, with appropriate annotation.&#xD;
&#xD;
    finalListHeadings = &#xD;
      Style[Framed[#], 16] &amp;amp; /@ &#xD;
       Flatten[{&amp;#034;No.&amp;#034;, &amp;#034;Name&amp;#034;, &amp;#034;Price&amp;#034;, listOptions, &#xD;
         &amp;#034;No. of shares in portfolio&amp;#034;}];&#xD;
    finalListwithHeadings = &#xD;
      Insert[finalList, finalListHeadings, {{1}, {-1}}];&#xD;
    &#xD;
    Rasterize[Take[finalListwithHeadings, 6] // TableForm, &#xD;
     RasterSize -&amp;gt; 2400, ImageSize -&amp;gt; 1200]&#xD;
&#xD;
![pic01][2]&#xD;
&#xD;
Here is an example of the portAtTime, with appropriate annotation.&#xD;
&#xD;
    portfolioAtTimeHeadings = &#xD;
      Style[Framed[#], 16] &amp;amp; /@ {&amp;#034;No.&amp;#034;, &amp;#034;Name&amp;#034;, &amp;#034;Price&amp;#034;, &amp;#034;No. of shares&amp;#034;, &#xD;
        &amp;#034;Sort value&amp;#034;, &amp;#034;Weight value&amp;#034;};&#xD;
    dateVar = RandomChoice[listDate];&#xD;
    portfolioAtTime = &#xD;
      Insert[portAtTime[dateVar], portfolioAtTimeHeadings, {{1}, {-1}}];&#xD;
    &#xD;
    Rasterize[Column[{dateVar, Take[portfolioAtTime, 12] // TableForm}], &#xD;
     RasterSize -&amp;gt; 1024, ImageSize -&amp;gt; 512]&#xD;
&#xD;
![pic02][3]&#xD;
&#xD;
Function callPlot[] is defined to expeditiously visualize the portfolio performance, in comparison with the Standard and Poor 500 Index if applicable (when there is no additional investment).&#xD;
The plot is saved in the global variable &amp;#034;plotVal&amp;#034;; and the annual rate of return is saved in the global variable &amp;#034;returnVal&amp;#034;.&#xD;
&#xD;
Function callExport[] will save the graph as a .PNG file, at the notebook&amp;#039;s directory. Function callPlot has to be called before callExport[].&#xD;
&#xD;
    (*callPlot*)&#xD;
    callPlot[] := Module[{},&#xD;
       frameLabel = Style[Framed[#], 12] &amp;amp; /@ {&amp;#034;Time&amp;#034;, &amp;#034;Relative Value&amp;#034;};&#xD;
       frameLable2 = {{Style[Framed[&amp;#034;Portolio Value&amp;#034;], 12], &#xD;
          Style[Framed[&amp;#034;Additional Investment&amp;#034;], 12]}, {Style[&#xD;
           Framed[&amp;#034;Time&amp;#034;], 12], None}};&#xD;
       &#xD;
       stringTotal = &#xD;
        ToString[&#xD;
         Round[QuantityMagnitude[&#xD;
           portValueTimeSeries[&amp;#034;FirstValue&amp;#034;] + Total[addFundTimeSeries] - &#xD;
            addFundTimeSeries[&amp;#034;FirstValue&amp;#034;]], 1]];&#xD;
       stringMax = &#xD;
        ToString[Round[QuantityMagnitude[Max[portValueTimeSeries]], 1]];&#xD;
       stringEnd = &#xD;
        ToString[&#xD;
         Round[QuantityMagnitude[portValueTimeSeries[&amp;#034;LastValue&amp;#034;]], 1]];&#xD;
       &#xD;
       firstVal = QuantityMagnitude[addFundTimeSeries[&amp;#034;FirstValue&amp;#034;]];&#xD;
       regularVal = QuantityMagnitude[investAmount];&#xD;
       dateVal = QuantityMagnitude[DateDifference[beginDate, endDate]]/&#xD;
        timePeriod;&#xD;
       lengthVal = Floor[dateVal];&#xD;
       totalVal = QuantityMagnitude[portValueTimeSeries[&amp;#034;LastValue&amp;#034;]];&#xD;
       &#xD;
       If[firstVal + regularVal != totalVal,&#xD;
        &#xD;
        CompoundExpression[&#xD;
         sol = &#xD;
          NSolve[(firstVal*(1 + interest)^lengthVal + &#xD;
                regularVal ((1 + interest)^lengthVal - 1)/interest) (1 + &#xD;
                 interest)^(dateVal - lengthVal) == totalVal, interest, &#xD;
            Reals][[1]];&#xD;
         returnVal = ((1 + interest)^(365.25/timePeriod) - 1) //. sol;],&#xD;
        &#xD;
        returnVal = 0];&#xD;
       stringReturn = ToString[PercentForm[returnVal, 4]];&#xD;
       &#xD;
       (*&#xD;
       stringReturn=ToString[PercentForm[QuantityMagnitude[(Exp[Log[&#xD;
       portValueTimeSeries[&amp;#034;LastValue&amp;#034;]/Total[addFundTimeSeries]]/(&#xD;
       QuantityMagnitude[DateDifference[beginDate,endDate]]/365.25)]-1;)],&#xD;
       4]];&#xD;
       &#xD;
       stringTotal=StringTake[StringPadRight[ToString[portValueTimeSeries[&#xD;
       &amp;#034;FirstValue&amp;#034;]+Total[addFundTimeSeries]-addFundTimeSeries[&#xD;
       &amp;#034;FirstValue&amp;#034;]],9,&amp;#034;0&amp;#034;],9];&#xD;
       stringMax=StringTake[StringPadRight[ToString[Max[&#xD;
       portValueTimeSeries]],9,&amp;#034;0&amp;#034;],9];&#xD;
       stringEnd=StringTake[StringPadRight[ToString[portValueTimeSeries[&#xD;
       &amp;#034;LastValue&amp;#034;]],9,&amp;#034;0&amp;#034;],9];&#xD;
       stringReturn=StringTake[StringPadRight[ToString[PercentForm[Exp[&#xD;
       Log[portValueTimeSeries[&amp;#034;LastValue&amp;#034;]/(portValueTimeSeries[&#xD;
       &amp;#034;FirstValue&amp;#034;]+Total[addFundTimeSeries]-addFundTimeSeries[&#xD;
       &amp;#034;FirstValue&amp;#034;])]/QuantityMagnitude[DateDifference[beginDate,endDate,&#xD;
       &amp;#034;Year&amp;#034;]]]-1,5]],5,&amp;#034;0&amp;#034;],5];&#xD;
       *)&#xD;
       &#xD;
       plotLabel = &#xD;
        Style[Framed[&#xD;
          StringJoin[&amp;#034;Total investment: $&amp;#034;, stringTotal, &#xD;
           &amp;#034;. Annual return: &amp;#034;, stringReturn, &amp;#034;\nPortfolio value max: $&amp;#034;, &#xD;
           stringMax, &amp;#034;; end: $&amp;#034;, stringEnd]], 16];&#xD;
       &#xD;
       max = Max[&#xD;
         Min[QuantityMagnitude[Max[portValueTimeSeriesRatio]], 12], &#xD;
         Max[sp500Ratio]];&#xD;
       min = Min[&#xD;
         Max[QuantityMagnitude[Min[portValueTimeSeriesRatio]], -1], &#xD;
         Min[sp500Ratio]];&#xD;
       plotVal = If[dailyInvest == 0,&#xD;
         DateListPlot[{portValueTimeSeriesRatio, sp500Ratio, &#xD;
           addFundTimeSeriesRatio}, FrameLabel -&amp;gt; frameLabel, &#xD;
          PlotLabel -&amp;gt; plotLabel, PlotRange -&amp;gt; {Automatic, {0, max}}, &#xD;
          PlotStyle -&amp;gt; {Thick, Thick}, Joined -&amp;gt; {True, True, False}, &#xD;
          Filling -&amp;gt; {1 -&amp;gt; Axis, &#xD;
            2 -&amp;gt; {{1}, {None, &#xD;
               Directive[Opacity[0.3], &#xD;
                ColorData[97, &amp;#034;ColorList&amp;#034;][[2]]]}}}, &#xD;
          FillingStyle -&amp;gt; Opacity[0.3], &#xD;
          PlotLegends -&amp;gt; &#xD;
           Placed[{&amp;#034;Portfolio&amp;#034;, &amp;#034;SP500&amp;#034;, &amp;#034;add&amp;#034;}, {Left, Top}], &#xD;
          ImageSize -&amp;gt; Large],&#xD;
         &#xD;
         addFundTimeSeriesRescaled = &#xD;
          addFundTimeSeries/addFundTimeSeries[&amp;#034;LastValue&amp;#034;]*&#xD;
           Max[portValueTimeSeries]/2;&#xD;
         DateListPlot[{portValueTimeSeries, addFundTimeSeriesRescaled}, &#xD;
          FrameLabel -&amp;gt; frameLable2, PlotLabel -&amp;gt; plotLabel, &#xD;
          PlotRange -&amp;gt; {Automatic, {0, &#xD;
             QuantityMagnitude[Max[portValueTimeSeries]]}}, &#xD;
          FrameTicks -&amp;gt; {{Table[&#xD;
              x Round[Max[portValueTimeSeries], 5]/5, {x, 0, 4}], &#xD;
             Table[{x Max[portValueTimeSeries]/4, &#xD;
               x addFundTimeSeries[&amp;#034;LastValue&amp;#034;]/2}, {x, 1, &#xD;
               3}]}, {Automatic, None}}, PlotStyle -&amp;gt; {Thick, Thick}, &#xD;
          Joined -&amp;gt; {True, False}, Filling -&amp;gt; {1 -&amp;gt; Axis}, &#xD;
          FillingStyle -&amp;gt; Opacity[0.3], &#xD;
          PlotLegends -&amp;gt; Placed[{&amp;#034;Portfolio&amp;#034;, &amp;#034;add&amp;#034;}, {Left, Top}], &#xD;
          ImageSize -&amp;gt; Large]&#xD;
         ]&#xD;
       ];&#xD;
    &#xD;
    callExport[plotVar_] := Export[&#xD;
       StringJoin[&amp;#034;plot&amp;#034;, ToString[plotVar],&#xD;
        StringPadLeft[ToString[sizePortfolio], 3, &amp;#034;0&amp;#034;],&#xD;
        StringTake[ToString[optionTake], 2],&#xD;
        StringPadLeft[ToString[timePeriod], 3, &amp;#034;0&amp;#034;],&#xD;
        &amp;#034;.png&amp;#034;&#xD;
        ]&#xD;
       , plotVal];&#xD;
    &#xD;
    callPlot[]&#xD;
    Hold[callExport[]];&#xD;
&#xD;
![pic03][4]&#xD;
&#xD;
V. Explicit quality-control: checking the model manually&#xD;
--------&#xD;
The model was explicitly checked to assure that it does what it is designed to do, given appropriate input data. The quality-control process is readily available using the following block of code.&#xD;
(Again, the  sort value and weight value are derived from the day immediately before, not the current day of portfolio balancing.)&#xD;
&#xD;
    timePeriod = 112;&#xD;
    sizePortfolio = 5;&#xD;
    taxRate = 0.4;&#xD;
    initialInvest = 100.00;&#xD;
    dailyInvest = 0.00;&#xD;
    optionWholeShare = False;&#xD;
    &#xD;
    beginDate = DateObject[&amp;#034;2014-07-01&amp;#034;];&#xD;
    endDate = DateObject[&amp;#034;2019-07-01&amp;#034;];&#xD;
    &#xD;
    funcSort[x1_, x2_, x3_, x4_, x5_] := x1;&#xD;
    funcWeight[x1_, x2_, x3_, x4_, x5_] := (2 Abs[x5 - x4])/(x5 + x4);&#xD;
    optionEqualWeight = False;&#xD;
    &#xD;
    callFunc[];&#xD;
    &#xD;
    listDate;&#xD;
    listIndexTest = &#xD;
      Flatten[Table[portAtTime[listDate[[q]]][[All, 1]], {q, 1, 10}]];&#xD;
    &#xD;
    portfolioAtTimeHeadings = &#xD;
      Style[Framed[#], 16] &amp;amp; /@ {&amp;#034;No.&amp;#034;, &amp;#034;Name&amp;#034;, &amp;#034;Price&amp;#034;, &amp;#034;No. of shares&amp;#034;, &#xD;
        &amp;#034;Sort value&amp;#034;, &amp;#034;Weight value&amp;#034;};&#xD;
    finalListHeadings = &#xD;
      Style[Framed[#], 16] &amp;amp; /@ &#xD;
       Flatten[{&amp;#034;No.&amp;#034;, &amp;#034;Name&amp;#034;, &amp;#034;Price&amp;#034;, listOptions}];&#xD;
    &#xD;
    For[h = 1, h &amp;lt;= 2, h++,&#xD;
     col1x = MapAt[QuantityMagnitude[#[DatePlus[listDate[[h]], -1]]] &amp;amp;, &#xD;
       Select[masterThread, MemberQ[listIndexTest, #[[1]]] &amp;amp;], {All, &#xD;
        Table[n, {n, 3, Length[listOptions] + 3}]}];&#xD;
     col1 = Insert[col1x, finalListHeadings, {{1}, {-1}}];&#xD;
     &#xD;
     col2x = portAtTime[listDate[[h]]];&#xD;
     col2 = Insert[col2x, portfolioAtTimeHeadings, {{1}, {-1}}];&#xD;
     &#xD;
     Rasterize[TableForm[{&#xD;
         Rasterize[listDate[[h]]],&#xD;
         Style[&#xD;
          StringJoin[&amp;#034;Portfolio&amp;#039;s value: $&amp;#034;, &#xD;
           ToString[QuantityMagnitude[portValue[listDate[[h]]]]]], 16],&#xD;
         &#xD;
         {Style[Framed[&amp;#034;Sublist from list of all Stocks, previous day&amp;#034;], &#xD;
           16],&#xD;
          &amp;#034;      &amp;#034;,&#xD;
          Style[Framed[&amp;#034;Portfolio, rebalancing day&amp;#034;], 16]},&#xD;
         &#xD;
         {col1 // TableForm,&#xD;
          &amp;#034;      &amp;#034;,&#xD;
          col2 // TableForm}&#xD;
         }, TableAlignments -&amp;gt; {Left, Top}],&#xD;
       RasterSize -&amp;gt; 2048, ImageSize -&amp;gt; 1024] // Print;&#xD;
     ]&#xD;
&#xD;
![pic04][5]&#xD;
![pic05][6]&#xD;
&#xD;
VI. Analysis of investment strategies&#xD;
--------&#xD;
Since market conditions vary with time, the investment strategies are evaluated and compared using the same set of initial inputs, which is prescribed to best represents the current market conditions:&#xD;
&#xD;
- taxRate 40%&#xD;
&#xD;
- beginDate July 01st, 2014&#xD;
&#xD;
- endDate July 01st, 2019&#xD;
	&#xD;
The function reEvaluateFunc[] simplifies the model&amp;#039;s implementation, providing both the graph of the portfolio&amp;#039;s performance and the annual return.&#xD;
&#xD;
        taxRate = 0.4;&#xD;
        initialInvest = 100.00;&#xD;
        dailyInvest = 0.00;&#xD;
        optionWholeShare = False;&#xD;
        &#xD;
        beginDate = DateObject[&amp;#034;2014-07-01&amp;#034;];&#xD;
        endDate = DateObject[&amp;#034;2019-07-01&amp;#034;];&#xD;
        &#xD;
        reEvaluateFunc[sizePortfolioVar_, optionTakeVar_, timePeriodVar_, &#xD;
           export_] := &#xD;
          Module[{o = optionTakeVar, t = timePeriodVar, s = sizePortfolioVar, &#xD;
            ex = export},&#xD;
           timePeriod = t;&#xD;
           sizePortfolio = s;&#xD;
           optionTake = o;&#xD;
           &#xD;
           callFunc[];&#xD;
           callPlot[];&#xD;
           If[ex == True, callExport[]];&#xD;
           &#xD;
           {plotVal, returnVal}&#xD;
           &#xD;
           ];&#xD;
&#xD;
## a) The sorted and weighted by price strategy ##&#xD;
The  sorted and weighted by price portfolio is one of the most common and simple strategies.&#xD;
This strategy results in equal number of shares for the stocks in portfolio (almost equal actually, since price of the day before adjustment is used as weight, but portfolio value is distributed to price of adjustment day).&#xD;
&#xD;
    funcSort[x1_, x2_, x3_, x4_, x5_] := x1 ;&#xD;
    funcWeight[x1_, x2_, x3_, x4_, x5_] := x1;&#xD;
    optionEqualWeight = False;&#xD;
    &#xD;
    plota11 = reEvaluateFunc[10, &amp;#034;high&amp;#034;, 056, False][[1]];&#xD;
    plota21 = reEvaluateFunc[10, &amp;#034;high&amp;#034;, 014, False][[1]];&#xD;
    plota31 = reEvaluateFunc[60, &amp;#034;high&amp;#034;, 056, False][[1]];&#xD;
    plota41 = reEvaluateFunc[60, &amp;#034;high&amp;#034;, 014, False][[1]];&#xD;
    &#xD;
    plota12 = reEvaluateFunc[10, &amp;#034;mid&amp;#034;, 056, False][[1]];&#xD;
    plota22 = reEvaluateFunc[10, &amp;#034;mid&amp;#034;, 014, False][[1]];&#xD;
    plota32 = reEvaluateFunc[60, &amp;#034;mid&amp;#034;, 056, False][[1]];&#xD;
    plota42 = reEvaluateFunc[60, &amp;#034;mid&amp;#034;, 014, False][[1]];&#xD;
    &#xD;
    plota13 = reEvaluateFunc[10, &amp;#034;low&amp;#034;, 056, False][[1]];&#xD;
    plota23 = reEvaluateFunc[10, &amp;#034;low&amp;#034;, 014, False][[1]];&#xD;
    plota33 = reEvaluateFunc[60, &amp;#034;low&amp;#034;, 056, False][[1]];&#xD;
    plota43 = reEvaluateFunc[60, &amp;#034;low&amp;#034;, 014, False][[1]];&#xD;
&#xD;
    k = 32;&#xD;
    tabLabel = &#xD;
      Style[Framed[&#xD;
        &amp;#034;Portfolio&amp;#039;s value, comparing to S&amp;amp;P500\nSorted and Weighted by \&#xD;
    Price&amp;#034;], 1.25 k];&#xD;
    row1 = Style[Framed[&amp;#034;Base Case:\nperiod 56\nsize 10&amp;#034;], k];&#xD;
    row2 = Style[Framed[&amp;#034;\[DownArrow]period 14\nsize 10&amp;#034;], k];&#xD;
    row3 = Style[Framed[&amp;#034;period 56\n\[UpArrow]size 60&amp;#034;], k];&#xD;
    row4 = Style[Framed[&amp;#034;\[DownArrow]period 14\n\[UpArrow]size 60&amp;#034;], k];&#xD;
    col1 = Style[Framed[&amp;#034;Largest Stocks&amp;#034;], k];&#xD;
    col2 = Style[Framed[&amp;#034;Middle Stocks&amp;#034;], k];&#xD;
    col3 = Style[Framed[&amp;#034;Smallest Stocks&amp;#034;], k];&#xD;
    &#xD;
    plotLista = {&#xD;
       {&amp;#034;&amp;#034;, col1, col2, col3},&#xD;
       {row1, plota11, plota12, plota13},&#xD;
       {row2, plota21, plota22, plota23},&#xD;
       {row3, plota31, plota32, plota33},&#xD;
       {row4, plota41, plota42, plota43},&#xD;
       {&amp;#034;&amp;#034;, tabLabel, SpanFromLeft, SpanFromLeft}};&#xD;
    Rasterize[TableForm[plotLista, TableAlignments -&amp;gt; Center]]&#xD;
&#xD;
![pic06][7]&#xD;
&#xD;
For this simple investment strategy:&#xD;
&#xD;
- a longer period of adjustment - a less frequent portfolio rebalancing schedule would generally yield a significantly better return (comparing row 1 and row 2, row 3 and row 4).&#xD;
&#xD;
- independent of how the stocks are chosen (largest, middle, and smallest, with respect to the sorting criteria), the size of the portfolio does not seem to affect portfolio&amp;#039;s performance: gaining portfolios remains gaining, and losing portfolios remains losing (comparing row 1 and row 3, row 2 and row 4).&#xD;
	&#xD;
Among the twelves scenarios investigated for this investment strategy, the scenario of choosing the smallest stocks and holding them for a longer period of time seems to be nearly as profitable as passive investing in SP500 Index, yielding a 1.50 times profit, corresponding to an annual return of 4.68%.&#xD;
&#xD;
## b) The sorted by price, equally weighted strategy ##&#xD;
This investment strategy is very similar to its cousin above: instead of equal number of share, each stock in the portfolio receive an equal amount of investment.&#xD;
&#xD;
    funcSort[x1_, x2_, x3_, x4_, x5_] := x1;&#xD;
    funcWeight[x1_, x2_, x3_, x4_, x5_] := x1;&#xD;
    optionEqualWeight = True;&#xD;
    &#xD;
    plotb11 = reEvaluateFunc[10, &amp;#034;high&amp;#034;, 056, False][[1]];&#xD;
    plotb12 = reEvaluateFunc[10, &amp;#034;mid&amp;#034;, 056, False][[1]];&#xD;
    plotb13 = reEvaluateFunc[10, &amp;#034;low&amp;#034;, 056, False][[1]];&#xD;
&#xD;
    k = 32;&#xD;
    tabLabel = &#xD;
      Style[Framed[&#xD;
        &amp;#034;Portfolio&amp;#039;s value, comparing to S&amp;amp;P500\nSorted by Price, Equally \&#xD;
    Weighted&amp;#034;], 1.25 k];&#xD;
    row1 = Style[Framed[&amp;#034;period 56\nsize 10&amp;#034;], k];&#xD;
    col1 = Style[Framed[&amp;#034;Largest Stocks&amp;#034;], k];&#xD;
    col2 = Style[Framed[&amp;#034;Middle Stocks&amp;#034;], k];&#xD;
    col3 = Style[Framed[&amp;#034;Smallest Stocks&amp;#034;], k];&#xD;
    &#xD;
    plotListb = {&#xD;
       {&amp;#034;&amp;#034;, col1, col2, col3},&#xD;
       {row1, plotb11, plotb12, plotb13},&#xD;
       {&amp;#034;&amp;#034;, tabLabel, SpanFromLeft, SpanFromLeft}};&#xD;
    Rasterize[TableForm[plotListb, TableAlignments -&amp;gt; Center]]&#xD;
&#xD;
![pic07][8]&#xD;
&#xD;
The sorted by price, equally weighted strategy performs a bit better comparing to its relative (sorted and weighted by price).&#xD;
Nevertheless, it remains inferior to passively investing in SP500 Index: it only gives an annual return of 6.78%, similar to SP500.&#xD;
&#xD;
## c) The sorted by volume, weighted by market capitalization strategy ##&#xD;
&#xD;
    funcSort[x1_, x2_, x3_, x4_, x5_] := x3;&#xD;
    funcWeight[x1_, x2_, x3_, x4_, x5_] := x2;&#xD;
    optionEqualWeight = False;&#xD;
    &#xD;
    plotc11 = reEvaluateFunc[10, &amp;#034;high&amp;#034;, 056, False][[1]];&#xD;
    plotc12 = reEvaluateFunc[10, &amp;#034;mid&amp;#034;, 056, False][[1]];&#xD;
    plotc13 = reEvaluateFunc[10, &amp;#034;low&amp;#034;, 056, False][[1]];&#xD;
&#xD;
    k = 32;&#xD;
    tabLabel = &#xD;
      Style[Framed[&#xD;
        &amp;#034;Portfolio&amp;#039;s value, comparing to S&amp;amp;P500\nSorted by Volume, \&#xD;
    Weighted by Market Cap.&amp;#034;], 1.25 k];&#xD;
    row1 = Style[Framed[&amp;#034;period 56\nsize 10&amp;#034;], k];&#xD;
    col1 = Style[Framed[&amp;#034;Largest Stocks&amp;#034;], k];&#xD;
    col2 = Style[Framed[&amp;#034;Middle Stocks&amp;#034;], k];&#xD;
    col3 = Style[Framed[&amp;#034;Smallest Stocks&amp;#034;], k];&#xD;
    &#xD;
    plotListc = {&#xD;
       {&amp;#034;&amp;#034;, col1, col2, col3},&#xD;
       {row1, plotc11, plotc12, plotc13},&#xD;
       {&amp;#034;&amp;#034;, tabLabel, SpanFromLeft, SpanFromLeft}};&#xD;
    Rasterize[TableForm[plotListc, TableAlignments -&amp;gt; Center]]&#xD;
&#xD;
![pic08][9]&#xD;
&#xD;
This strategy is abysmal: it manages to earn significantly less than the SP500 Index, or even lose money over time.&#xD;
However, it indicates perhaps a relevant strategy of shorting (selling) these portfolios - instead of longing (buying) them - might be profitable.&#xD;
&#xD;
## d) The sorted and weighted by market capitalization strategy ##&#xD;
&#xD;
    funcSort[x1_, x2_, x3_, x4_, x5_] := x2;&#xD;
    funcWeight[x1_, x2_, x3_, x4_, x5_] := x2;&#xD;
    optionEqualWeight = False;&#xD;
    &#xD;
    beginDate = DateObject[&amp;#034;2014-07-01&amp;#034;];&#xD;
    endDate = DateObject[&amp;#034;2019-07-01&amp;#034;];&#xD;
    plotd11 = reEvaluateFunc[10, &amp;#034;high&amp;#034;, 056, False][[1]];&#xD;
    plotd12 = reEvaluateFunc[10, &amp;#034;mid&amp;#034;, 056, False][[1]];&#xD;
    plotd13 = reEvaluateFunc[10, &amp;#034;low&amp;#034;, 056, False][[1]];&#xD;
    &#xD;
    beginDate = DateObject[&amp;#034;2009-07-01&amp;#034;];&#xD;
    endDate = DateObject[&amp;#034;2019-07-01&amp;#034;];&#xD;
    plotd21 = reEvaluateFunc[10, &amp;#034;high&amp;#034;, 056, False][[1]];&#xD;
    plotd22 = reEvaluateFunc[10, &amp;#034;mid&amp;#034;, 056, False][[1]];&#xD;
    plotd23 = reEvaluateFunc[10, &amp;#034;low&amp;#034;, 056, False][[1]];&#xD;
    &#xD;
    beginDate = DateObject[&amp;#034;2004-07-01&amp;#034;];&#xD;
    endDate = DateObject[&amp;#034;2019-07-01&amp;#034;];&#xD;
    plotd31 = reEvaluateFunc[10, &amp;#034;high&amp;#034;, 056, False][[1]];&#xD;
    plotd32 = reEvaluateFunc[10, &amp;#034;mid&amp;#034;, 056, False][[1]];&#xD;
    plotd33 = reEvaluateFunc[10, &amp;#034;low&amp;#034;, 056, False][[1]];&#xD;
&#xD;
    k = 32;&#xD;
    tabLabel = &#xD;
      Style[Framed[&#xD;
        &amp;#034;Portfolio&amp;#039;s value, comparing to S&amp;amp;P500\nSorted and Weighted by \&#xD;
    Market Capitalization&amp;#034;], 1.25 k];&#xD;
    row1 = Style[Framed[&amp;#034;period 56\nsize 10\n5 years&amp;#034;], k];&#xD;
    row2 = Style[Framed[&amp;#034;10 years&amp;#034;], k];&#xD;
    row3 = Style[Framed[&amp;#034;15 years&amp;#034;], k];&#xD;
    col1 = Style[Framed[&amp;#034;Largest Stocks&amp;#034;], k];&#xD;
    col2 = Style[Framed[&amp;#034;Middle Stocks&amp;#034;], k];&#xD;
    col3 = Style[Framed[&amp;#034;Smallest Stocks&amp;#034;], k];&#xD;
    &#xD;
    plotListd = {&#xD;
       {&amp;#034;&amp;#034;, col1, col2, col3},&#xD;
       {row1, plotd11, plotd12, plotd13},&#xD;
       {row2, plotd21, plotd22, plotd23},&#xD;
       {row3, plotd31, plotd32, plotd33},&#xD;
       {&amp;#034;&amp;#034;, tabLabel, SpanFromLeft, SpanFromLeft}};&#xD;
    Rasterize[TableForm[plotListd, TableAlignments -&amp;gt; Center]]&#xD;
&#xD;
![pic09][10]&#xD;
&#xD;
Theoretically, this strategy looks wonderful for stocks of small market capitalization: an annual return of 15.8% is impressive.&#xD;
It consistently performs significantly better than SP500 Index over different time frame (data not shown): 5, 10, 15 years till today.&#xD;
However, the strategy&amp;#039;s consistent performance instills doubts of systematic errors, either in the model itself or in the input data (as discussed in the next section). &#xD;
&#xD;
VII. Discussion&#xD;
--------&#xD;
&#xD;
A versatile computation model for portfolio&amp;#039;s performance was derived, which allows investment strategies to be analyzed and quantified. The model shows that a less frequently adjusted portfolio seems to perform better, supporting the buy-and-hold tactic. The model also indicate that the size of the portfolio does not exert a strong effect on the strategy&amp;#039;s overall performance.&#xD;
&#xD;
Generally, the model suggests that portfolios of small stocks (with respect to the sorting criteria) seem to outperform portfolios of larger stocks.&#xD;
&#xD;
There are two know systematic errors regarding the input data, which may significantly distort the results the model provided:&#xD;
&#xD;
- The stocks in Entity Class SP500 are the current components of the Standard and Poor 500 Index. Since the composition of SP500 changes over time, some of these stocks might not be included in the index until recently. As SP500 signifies large, successful companies, choosing the stocks that would be in SP500 in the future, but not at the time of portfolio rebalancing, would result in survivor bias. The same is true for excluding stocks that were in SP500 in the past, but is no longer a component of the index (for example, Enron). This survivor bias is expected to be much less significant with recent time period (e.g. past 5 years), comparing to more distant time period (e.g. past 10, 15 years).&#xD;
&#xD;
- At least one stock received insufficient property, which affects how the stocks are chosen and weighed: as of 2019-07-28, the FinancialData[] call for Loews, &amp;#034;NYSE:L&amp;#034;, only provide a timeseries of price up to 2013-11-05, which means price after that day is erroneous (due to missing value and interpolation), as shown in the block of codes below.&#xD;
&#xD;
        FinancialData[Entity[&amp;#034;Financial&amp;#034;, &amp;#034;NYSE:L&amp;#034;], &amp;#034;Price&amp;#034;]&#xD;
        FinancialData[Entity[&amp;#034;Financial&amp;#034;, &amp;#034;NYSE:L&amp;#034;], &amp;#034;Price&amp;#034;, All][&amp;#034;LastValue&amp;#034;]&#xD;
        FinancialData[Entity[&amp;#034;Financial&amp;#034;, &amp;#034;NYSE:L&amp;#034;], &amp;#034;Price&amp;#034;,&#xD;
                      {2013-01-01, 2019-07-01}]&#xD;
&#xD;
Just For Fun&#xD;
--------&#xD;
![just for fun][11]&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=pic01.png&amp;amp;userId=1707333&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=pic01.png&amp;amp;userId=1707333&#xD;
  [3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=pic02.png&amp;amp;userId=1707333&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=pic03.png&amp;amp;userId=1707333&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=pic04.png&amp;amp;userId=1707333&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=pic05.png&amp;amp;userId=1707333&#xD;
  [7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=pic06.png&amp;amp;userId=1707333&#xD;
  [8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=pic07.png&amp;amp;userId=1707333&#xD;
  [9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=pic08.png&amp;amp;userId=1707333&#xD;
  [10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=pic09.png&amp;amp;userId=1707333&#xD;
  [11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=2019-07-09photoforpresentation.PNG&amp;amp;userId=1707333</description>
    <dc:creator>Nam Tran</dc:creator>
    <dc:date>2019-07-11T16:21:18Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1046869">
    <title>[?] Change x axis units from seconds to minutes?</title>
    <link>https://community.wolfram.com/groups/-/m/t/1046869</link>
    <description>Is there any way to overwrite the x-axis values in a plot?&#xD;
&#xD;
I have numerical solution to a differential equation, the solution is plotted against time in seconds. However, I want to change the x-scale of my plot to show minutes, without having to go back and solve the differential equation again.&#xD;
&#xD;
    Plot[Evaluate[(((y[x]) /. solutionNum))], {x, 0, signalLength}, &#xD;
           PlotRange -&amp;gt; {{0, signalLength}, {All, All}}, &#xD;
           FrameLabel -&amp;gt; {&amp;#034;time / s&amp;#034;, &amp;#034;temperature / ºC&amp;#034; }, PlotLegends -&amp;gt; {&amp;#034;Model&amp;#034;}];&#xD;
&#xD;
I want to overwrite the x-axis values to show for instance 0-250 minutes, and not 0-15000 seconds, without having to redo my soluton .&#xD;
&#xD;
Thanks in advance!&#xD;
![enter image description here][1]&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=result.JPG&amp;amp;userId=980020</description>
    <dc:creator>Sara K</dc:creator>
    <dc:date>2017-03-29T13:56:54Z</dc:date>
  </item>
</rdf:RDF>

