Community RSS Feed
http://community.wolfram.com
RSS Feed for Wolfram Community showing any discussions in tag Wolfram Scienceattachment.php?postid=2617 sorted by activeOptimization with a strange constraint
http://community.wolfram.com/groups/-/m/t/1270736
Table[NMaximize[{NIntegrate[(a*(1 - 0.25*z - (1 - 0.25)*x)*x +
a*(0.25*z - y + (1 - 0.25)*x)*y)/b, {a, 0, b}],
z = Min[1, (x - y*0.3)/(1 - 0.3)], b*(1 - y) <= 1,
0 <= y <= x <= 1}, {x, y}], {b, 1, 1.5, 0.1}]
I am trying to numerically solve an optimization problem (for x and y, for some b values). The problem has an integration in it. Interestingly, there is another variable z, which is a function of x and y, but cannot be greater than 1 (therefore I use Min function).
Integration have issues because of the Min function. Any ideas?
Cheers,
OvuncOvunc Yilmaz2018-01-22T21:35:55ZUse wolframscript under raspbian stretch?
http://community.wolfram.com/groups/-/m/t/1270331
Does anyone know why wolframscript does not work under raspbian stretch? Executing "whereis wolframscript" at the terminal gives no result, however "whereis env" results in "env: /usr/bin/env" indicating that the env executable is there?
Moreover, is this due to some bug/oversight or is wolframscript invoked differently under stretch versus jessie?
Has anyone else had this experience with RPi3?
CheersFrancesco LaTella2018-01-22T09:03:19ZMeal Planning in the Wolfram Language
http://community.wolfram.com/groups/-/m/t/1263860
[![enter image description here][3]][2]
## The Problem ##
As a software developer, I've always loved the challenge of taking an aspect of life and trying to streamline it with code. There are so many things we do day-to-day that can be helped by some code to "grease the wheels".
Take meal planning, for example. There are a variety of tasks here: Thinking of meal ideas, aggregating the list of ingredients, checking what ingredients you already have to produce a final shopping list, grocery shopping, and then eventually making those meals, at which point one typically needs the recipes handy.
When I do the above things by hand, I find them cumbersome. First of all, as I'm sitting there with pen and paper, I struggle to conjure up meal ideas. Looking through recipe books (etc) can be mildly helpful, but it's still slow going. Once I have some recipes picked out, I find it tedious aggregating the ingredients -- it all feels like something that could be done automatically, so why am I doing it by hand? When grocery shopping, I feel disorganized. It's hard to mentally sort the grocery list into where things are in the store, so I will often miss an item or two and have to retrace my steps to get them. Or, I will have forgotten what isle things are in, so I wander around aimlessly. It's all so inefficient! And finally, when I make the recipes, I find it unfortunate that I have to go find a recipe book and re-find what page the recipe is on.
Fortunately, it's not that hard to solve all of the above things with some code, and the Wolfram Language is ideal for these sorts of things.
## Choosing Meals ##
There are a variety of ways to do this, some of them very simple, some of them very complex. For instance, you could write an algorithm to create a meal plan automatically that balances nutritional elements. What I've done to get the ball rolling is simply to have a function that "rolls the dice" and presents three random recipes to me. If I like any of them, I click on the recipe and it adds it to my meal plan. Otherwise, I "roll the dice" again. This may sound somewhat inefficient, but it often takes less than 30 seconds for me to create a nice meal plan.
I love how easy the Wolfram Language makes simple UI development. I have a utility function called `SelectUI` which is just like the language's `Select` function, but gives you buttons to select the things you want. With a function like that, building a little UI to select recipes is very easy. In the image below, the yellow buttons are items that have been selected.
![Choosing Meals][4]
## Creating a Shopping List ##
Now that we have a list of recipes, we want to create a shopping list. To make this possible, we need a symbolic representation of a recipe and its ingredients. Here's the representation I chose:
Recipe[
"Name" -> "Spaghetti",
"Label" -> "Spaghetti",
"Ingredients" -> {
RecipeLine[
"FoodQuantity" -> FoodQuantity[
"Food" -> Entity["Food", "SpaghettiNoodles"],
"Quantity" -> Quantity[450, "Grams"]
],
"RawString" -> "450 g of spaghetti noodles"
],
RecipeLine[
"FoodQuantity" -> FoodQuantity[
"Food" -> Entity["Food", "PastaSauce"],
"Quantity" -> Quantity[800, "Milliliters"]
],
"RawString" -> "800 ml pasta sauce"
],
RecipeLine[
"FoodQuantity" -> FoodQuantity[
"Food" -> Entity["Food", "GroundBeef"],
"Quantity" -> Quantity[1, "Pounds"]
],
"RawString" -> "1 lb ground beef"
]
},
"IngredientsString" -> "450 g of spaghetti noodles\n800 ml pasta sauce\n1 lb ground beef",
"SupperQ" -> True,
"LunchQ" -> False,
"SideQ" -> False,
"SaladQ" -> False,
"Instructions" -> ""
]
You'll notice that my symbolic representation is quite like a nested Asssociations, except that I'm using symbolic heads. Nested associations would also work well here. To make getting and setting keys easy, I have functions `Gett` and `Sett` which allow you to get and set keys on not only Associations but also lists of key/value pairs and headed expressions with key/value pairs.
Once we have this symbolic representation, we can create a first draft of our shopping list by taking the Union of the ingredients of each of our recipes.
The next step takes a bit more effort: If two recipes make use of ground beef, for example, then we'd like to replace the two FoodQuantity expressions with a single FoodQuantity that combines their Quantities. This is easy when both food quantities are a mass, or both are a volume, because we can just do:
Quantity[1, "Pounds"] + Quantity[500, "Grams"]
It's trickier if one of the quantities is a volume and the other is a mass. In that case, we need the density of the food. But this is another case where the Wolfram Language shines, because we can grab that data from Wolfram Alpha:
foodName = "Pasta";
WolframAlpha["density of " <> foodName, {{"Result", 1}, "Output"}]
## Pruning the Shopping List ##
Now that we have a shopping list, we need to prune it. ie. There's a good chance we have at least half of the things already in our kitchen.
To make this as efficient as possible, we should by default select all foods that have < 50% chance of being in the kitchen, and de-select all foods with > 50% chance. For each food, I've tagged it with a key/value pair called "Probability", making the default select easy to decide.
It's also somewhat helpful to sort the list of foods by the likelihood we have them, so that as you scroll down the list, you can pay very close attention to the things at the top (which are also selected by default) and can quickly scan over the things at the bottom of the list, which you almost certainly don't need to buy. (salt, pepper, flour, etc.)
Once again, we can whip up a UI in no time using a function like `SelectUI` to make it easy to prune the shopping list:
![Pruning the shopping list][5]
## Producing the Final Shopping List ##
We're ready to go shopping -- almost. Before we produce a PDF of our shopping list, we should first sort the foods by their location in the grocery store, and to label them in the shopping list by their location in the store. This is helpful for two reasons:
- It makes it very fast to flow through the store -- just look at what item is next in your list, and if you can't remember where it is, pay attention to the store location printed beside it.
- Avoids missing items and having to circle back for them.
Implementing this function took some elbow grease, because it requires knowing where foods are in the store. I took a pen and a notebook and spent about an hour and a half cataloging my local store. For each side of each isle, I divided it into sub-sections A/B/C/D/E/F/G/H, and for each of those sub-sections, I wrote down the food items that I've ever bought in the last 10 years. When I got home, I wrote a bit of parsing code using functions like `StringSplit` to turn those notes into an expression, after which it was easy to update my list of food expressions with their store locations.
Something that can be useful to have (such as when doing the above) is a way to take a food name like "ground beef" or "hamburger" and turn it into its normalized `Entity["Food", ...]` expression. The Wolfram Language's integration with Wolfram Alpha also makes this easy. Because I'm a bit of a low latency freak and enjoy writing parsing code, I have my own local linguistics and parser so that I can parse something like "1 lb of ground beef" in about 15 milliseconds. Maybe some day the Wolfram Language will support local parsing of things like this to give fast performance.
I have also labeled all of my food items with their "type", such as "Vegetable", "Fruit", "FrozenVegetable", "DairyProduct", "Oil", etc. etc. That way, when I add new food items in the future where I don't yet have a grocery store location for it, I can specify its type, and then the code can look at store locations of foods with the same type and use that to infer an intelligent default for where it may be in the store. Those store locations are printed with a question mark after them on my grocery list so that I'm aware it's just a guess, and I can note the exact location to add to my food items when I get home.
The order of the shopping list follows the order of store areas that I've given the code. It works well, but I'm tempted to geometrically model the store locations and use the `FindShortestTour` function to produce even more optimized tours through the store.
We now have our final shopping list. Using Wolfram Language's `CreateDocument` function, we can dynamically generate a notebook:
![Final shopping list][6]
The notebook I generate has an additional section for each recipe where I give its ingredients and instructions. That way, when I print it out, I can place the instructions beside the fridge where they are handy each evening, avoiding having to look things up in a recipe book.
My wife has complained that I'm wasting paper, so now I also use `CloudDeploy` to put the generated notebook in the cloud at a dependable URL so that she can click on a link in her bookmarks bar to see the recipe instructions. Maybe some day soon I'll kick my habit of printing out the recipes!
## Grocery Shopping ##
With my shopping list in hand, I head to the grocery store. I had never really enjoyed grocery shopping in the past, but now I find it exhilarating. How fast can I flow through the store and get back to the car? It's not uncommon for me to do it in 10 minutes now, where it might have taken me 25 minutes before.
It's also fun to keep stats on how quickly I can do the whole stack of tasks: Planning meals, grocery shopping, and putting the food away. My record so far is about 35 minutes. When life is this efficient, I find it much more fun and energizing.
## Video Demonstration ##
Please follow this link for a [Video Demonstration][7]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-01-22at12.50.11PM.png&userId=20103
[2]: https://www.youtube.com/watch?v=lr2i6RJi-U8
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=9954ScreenShot2018-01-22at12.50.11PM.png&userId=20103
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ChoosingMeals.png&userId=24639
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PruningShoppingList.png&userId=24639
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ShoppingList.png&userId=24639
[7]: https://www.youtube.com/watch?v=lr2i6RJi-U8Daniel Bigham2018-01-11T14:27:31Z3D Design in Mathematica: Generative Jewelry
http://community.wolfram.com/groups/-/m/t/1270499
*This article [originally appeared][1] The Mathematical Zorro blog*.
----------
![enter image description here][2]
I'll share a bit of Mathematica code that has helped me to add some ordered randomness to my art and jewelry. And we'll design a new piece of generative jewelry!
Before that, let me share something else I've been working on. In June of 2017 I gave myself a goal to share with the public each day one piece of jewelry I designed. Designing, refining, and posting took some effort, and I have completed my goal! In the process I designed some new jewelry that I really like, and I will be working over the coming months to develop them into coherent jewelry collections. I have been sharing on various social media accounts: @hanusadesign on [instagram][3], [facebook][4], [twitter][5], and [pinterest][6]. Be sure to follow me to see my latest work!
Now on to the Mathematica tutorial. What do I mean by ordered randomness? Compare the following sets of 100 random points:
![enter image description here][7]
While the points seem rather "random" in both sets, you can see that the points on the left often land rather close to each other while the points on the right are pretty regularly spaced. This last observation should tell you that the points on the right are not actually "random"! Indeed, the points on the left are chosen randomly using Mathematica's [RandomReal][8] command. (Even though the numbers are generated by a deterministic process in a computer program and thus inherently not completely random, we will say that pseudorandom is close enough for our purposes.) The command
ptlist = RandomReal[{-1, 1}, {100, 2}];
generates 100 pairs of real numbers that all fall between −1 and 1. On the other hand, the points on the right are chosen by a selection process in which we grow a list of points, starting with any point in the square. Then when we want to add a new point to the list, we generate a random point in the square and see if it is greater than a specified distance to any of the points already in our list. If so, it is added to our list; otherwise it is thrown out! Here is the code:
ptlist = {RandomReal[{-1, 1}, 2]};
While[Length[ptlist] < 100,
newpt = RandomReal[{-1, 1}, 2];
If[Min[Map[Norm[newpt - #] &, ptlist]] > .1,
ptlist = Append[ptlist, newpt]]]
Running the same code multiple times gives different sets of points.
## Generative jewelry
Let's take this idea and turn it into a nice piece of [generative jewelry][9], in that we don't actually know what it is going to look like before our program completes!
My goal is to create a piece of jewelry that is a collection of overlapping rings. We'll first generate a set of points and then construct rings centered at those points. We will work to complete three tasks to improve the aesthetic appeal of the final product:
1. The points should be lie in a circle instead of a square.
2. The points should be generously spaced.
3. The rings should be different sizes
For Task 1, we will specify a shape and ensure that each point that we consider is a member of that region. (Here we choose a circle, but you can easily modify it to be ANY region.) For Task 2, we will modify our selection process from above to add more distance between the points (radius .21 instead of .1) and have fewer points (50 instead of 100). By using our selection process, the rings won't overlap too awkwardly and it will be pleasing to the eye. The values I have chosen are purely by trial and error with a view toward making the proportions of the final product look good.
shape = Disk[{0, 0}, 1];
ptlist = {RandomReal[{-1, 1}, 2]};
While[! RegionMember[shape, ptlist[[1]]],
ptlist = {RandomReal[{-1, 1}, 2]}]
While[Length[ptlist] < 50, newpt = RandomReal[{-1, 1}, 2];
If[Min[Map[Norm[newpt - #] &, ptlist]] > .21
&& RegionMember[shape, newpt],
ptlist = Append[ptlist, newpt]]]
Graphics[{
{Lighter[Blue, .8], Rectangle[{-1, -1}, {1, 1}]},
{EdgeForm[{Black, Thick}], White, shape},
{Purple, Point[ptlist]}
}]
Notice that we have also ensured that the first point is also in the circular region. The result of this code looks like this:
![enter image description here][10]
Now we want to build a ring centered at each point. A basic torus that has an outer radius of .14 and tube radius of .03 looks like this:
torus[coords_] := Module[{thickness = .14, innerradius = .03},
ParametricPlot3D[{
( thickness + innerradius Cos[v]) Cos[u],
( thickness + innerradius Cos[v]) Sin[u],
innerradius Sin[v]} + Append[coords, 0],
{u, 0, 2 Pi}, {v, 0, 2 Pi}, Mesh -> None, PlotPoints -> 50]];
Mapping this function to the points in `ptlist` gives the following:
![enter image description here][11]
Now we need to attack Task 3, making the rings have different sizes. To do this we modify our torus function:
torus[coords_, thickness_] := Module[{innerradius = .03},
ParametricPlot3D[{
( thickness + innerradius Cos[v]) Cos[u],
( thickness + innerradius Cos[v]) Sin[u],
innerradius Sin[v]} + Append[coords, 0],
{u, 0, 2 Pi}, {v, 0, 2 Pi}, Mesh -> None, PlotPoints -> 50]];
and generate a set of random outer radii. I first chose the outer radii to be between .1 and .15, but when I displayed the rings, they were disconnected, which is not what we wanted
thicknesses = RandomReal[{.1, .15}, 50]
Show[MapThread[torus, {ptlist, thicknesses}], PlotRange -> All]
![enter image description here][12]
So I modified the the outer radii to be between .09 and .17. I definitely re-ran the code multiple times until I was happy with the final product. Here you go:
thicknesses = RandomReal[{.09, .17}, 50]
Show[MapThread[torus, {ptlist, thicknesses}], PlotRange -> All]
**Pro Tip**: Re-running the code always gives you a new arrangement. When you get a random arrangement that you like, you need to **save the data** that created it, so you can recreate it next time!
In essence, when working to create a piece of generative art, you impose randomness until you find something that you like, at which time you need to save this input so that this data will not change again — which seems to be the opposite of random! It was a revelation when I realized that adding randomness to my art involved saving the random data I generated.
## The Final Result
After exporting our final work to an STL, here is a rendering of our new piece of generative jewelry on Sketchfab:
[![enter image description here][13]][14]
And Shapeways gives the following beautiful rendering of [our pendant in Raw Bronze][15]:
[![enter image description here][18]][17]
The final 3D Printed pendant is the image at the top of the post.
And now you have the tools to make your own! If you have suggestions for how to modify this in an interesting way or for something else I should tackle, let me know. Happy New Year everyone!
[1]: http://blog.mathzorro.com/2017/07/generative.html
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-01-22at11.07.46AM.jpg&userId=20103
[3]: http://instagram.com/hanusadesign/
[4]: https://www.facebook.com/hanusadesign/
[5]: https://www.twitter.com/hanusadesign/
[6]: https://www.pinterest.com/hanusadesign/
[7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Mathematica_2017-06-26_21-45-59.png&userId=20103
[8]: https://reference.wolfram.com/language/ref/RandomReal.html
[9]: https://en.wikipedia.org/wiki/Generative_art
[10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=points.png&userId=20103
[11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=rings.png&userId=20103
[12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=disconnected.png&userId=20103
[13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-01-22at10.59.26AM.png&userId=20103
[14]: https://sketchfab.com/models/affe8a0915e14f55b8723ec3cd339092
[15]: http://shpws.me/OIrD
[16]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-01-22at11.02.37AM.png&userId=20103
[17]: http://shpws.me/OIrD
[18]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Shapeways.jpg&userId=1270503Christopher Hanusa2018-01-22T17:05:53Z[✓] Pick columns or rows of a matrix?
http://community.wolfram.com/groups/-/m/t/1270415
I work with random matrices made of 0 and 1. Once generated, I want to remove the columns that contains only zero's. I can easily identify these columns (as a list), and I can remove one column at a time. How to do it in one operation ? Here is how the nb starts:
m = 100; n = 10
A = RandomInteger[1, {m, n}]
Position [A, Table[0, n]]
...
An alternative would be to exclude from the start columns with only zero's.
Thanks for suggestions. Pierre Dehez, University of Louvain, Louvain-la-NeuvePierre Dehez2018-01-22T09:06:24ZMathematica Local WebServer on Mac OS X Failed to Start
http://community.wolfram.com/groups/-/m/t/1269849
I recently watched the video class on [Web Programming and Development][1] and was greatly intrigued by the ability to serve web related work locally before CloudDeploy'ing. In the video class, the StartWebServer function was used so I immediately stopped the on demand video to try it out. After realizing the **StartWebServer** command was not "standard" (at least not found in the standard Mathematica docs), I was able to uncover it lives in **HTTPHandling**.
I'm running Mathematica 11.2.0.0 on Mac OS 10.13.2 and executing the command below fails.
HTTPHandling`StartWebServer[ExportForm["Hello", "HTML"]]
The error message reported is:
WebServer: The HTTP server failed to start with error code None and stderr output:
EndOfFile.
Any ideas what I'm doing wrong? Perhaps there is some other dependency I need.
Regards.
[1]: http://www.wolfram.com/training/courses/wl050.htmlmacrod2018-01-20T21:50:46ZAvoid message error "MemoryAllocationFailure" with NonlinearModelFit?
http://community.wolfram.com/groups/-/m/t/1267668
This code has performed an exponential adjustment and gets the "ParameterErrors" and "RSquared" for a exponetial model and "NonlinearModelFit".
The code is running correctly for almost data ... However, for this data, attached in the code, Mathematica is freezing during the evaluation of "ParameterErrors" and "RSquared" and "ParameterTable".
Please. How can I evaluate this data without freezing and errors?
SystemException ["MemoryAllocationFailure"]
ClearAll["Global`*"]
ClearSystemCache[]
sizedistcum = {{1.12996, 0.}, {1.42366, 0.}, {1.7937, 0.}, {2.25992,
0.}, {2.84732, 0.}, {3.5874, 0.}, {4.51984, 0.}, {5.69464,
0.}, {7.1748, 0.}, {9.03968, 0.}, {11.3893, 0.}, {14.3496,
0.}, {18.0794, 0.}, {22.7786, 0.}, {28.6992, 0.}, {36.1587,
0.}, {45.5572, 0.}, {57.3984, 0.00215924}, {72.3175,
0.0283401}, {91.1143, 0.0537112}, {114.797, 0.0753036}, {144.635,
0.103104}, {182.229, 0.268826}, {229.594, 0.832659}, {289.27,
0.964372}, {364.457, 0.993522}, {459.187, 1.}, {578.54,
1.}, {728.914, 1.}, {918.375, 1.}, {1157.08, 1.}, {1457.83,
1.}, {1836.75, 1.}, {2314.16, 1.}, {2915.66, 1.}, {3673.5,
1.}, {4628.32, 1.}, {5831.32, 1.}, {7347., 1.}, {9256.64,
1.}, {11662.6, 1.}};
RRmodel = 1 - Exp[-(x/dm)^n];
nlm = NonlinearModelFit[sizedistcum, RRmodel, {{dm, 10}, {n, 1}}, x];
{{dm, n}} = {dm, n} /. nlm[{"BestFitParameters"}]
{{dmdev, ndev}} = nlm[{"ParameterErrors"}]
RRrsquared = nlm[{"RSquared"}]
nlm[{"ParameterTable"}]Gustavo Dacanal2018-01-18T13:46:12Z[✓] Correct format for NetChain?
http://community.wolfram.com/groups/-/m/t/1262168
I am trying to create a simple neural network with one hidden layer to recognise hand written characters from the MNIST training set. I would like my hidden layer to be an ElementwiseLayer[LogisticSigmoid] with 30 neurons. I would have expected the syntax for a linear layer to be
NetChain[{LinearLayer[30]},
"Input" -> NetEncoder[{"Image", {28, 28}, "Grayscale"}],
"Output" -> NetDecoder[{"Class", Range[0, 9]}]]
But this generates the error
"Specification NetDecoder[Class, ...]) is not compatible with port "Output", which must be a length-30 vector"
Does anyone have an idea what the correct syntax is to achieve what I want?
ThanksLenny Johnson2018-01-09T14:06:02Z[✓] Read a text file in the Wolfram language?
http://community.wolfram.com/groups/-/m/t/1262000
Hi ,
I am very new to Mathematica. I need to read inputs from the .text file for below code to perform arithematic operation i.e pfused=ad+bc
When I am trying with Import it is not performing operation, but its reading the text file, please any one help me to resolve the below issue.
v = Import["C:\\work\posit.txt", "Text"]
For[i = 1, i < Length[v], i = i + 4, a = v[i] ; d = v[i + 3]; b = v[i + 1]; c = v[i + 2]]
PArith :=
Module[{pnuma = a, pnumd=d,pnumb=b,pnumc=c , pfused},
pfused= pnuma*pnumd+pnumb*pnumc ;
Print[{pnuma, pnumd, pnumb, pnumc, pfused}]];
Print[N[{pnuma, pnumd, pnumb, pnumc, pfused}, 37]];GABBAR JADAV2018-01-09T05:36:14ZIncrement a String which is a number by 1 10 times?
http://community.wolfram.com/groups/-/m/t/1269460
I have a SQL statement that I need to change the year in the statement for a period of years. I need to essentially have let's say 10 SQL statements that increment the year by 1 for 10 times.
Part of the SQL statement is:
DateFrom = {d' 2013 - 01 - 01'}, DateTo = {d' 2013 - 01 - 01'},
So the year 2013 need to change to 2014 and than 2015 etc.
I have come up with the following but can't figure out how to reiterate it.
Any help would be appreciated...
StringReplace["DateTo={d'2013-01-01'},DateTo={d'2013-01-01'}", "2013" -> "2014"]
gives
"DateTo={d'2014-01-01'},DateTo={d'2014-01-01'}"
Thanks.
DavidDavid Kerr2018-01-20T16:36:13ZUse graphdata to plot linked numbers from a formula?
http://community.wolfram.com/groups/-/m/t/1267896
Can someone help me make a graph linking all the numbers that come from the use of a formula. I would like to link 1->3 making it the variable x->y1->x2-> y2 or any of the combination xa->xb-> ya-Yc. When I use the graphdata command it seems to make only the graph that is on the documentary page. For instance using the lines and the formula:
Thanks !!!
r=RandomInteger[300000000,{300}]
v1=RandomInteger[30000000,{300}]
m=(r^2-1)/2
v=(2*Pi*r-m*v1)/r
r1=r2-r2*Power[r2, (r2)^-1]
r2=Sqrt[((r^2-1)/2)^2+4*Pi^2*v^2-1-r^2+r^2*((r^2-1)/2)-0]
z=r1/r2
z3=Table[Mod[r2,r1],{r2,300},{r1,300}]
ListPlot[z3]Luis Felipe Massena Misiec2018-01-18T21:56:17ZCalculate minimum common differences?
http://community.wolfram.com/groups/-/m/t/1159745
![sketch][1] Can someone program something todo this? Calculate the least or greatest most different numbers between a series of numbers?
So far I came out with these lines, but nothing comes out...
Unprotect [Element]Unprotect [NotElement]Unprotect[NestWhile]Unprotect[a,a1,a2]Unprotect[Slot]
f[a1_]:= a&;&["|<a 1] ,[|>"a 1"\[Rule]a 1],|<=>"a1 "\[Rule] a1 "];
Block
Thread[f[{a},{a1,a2},List AllTrue]]
e=Intersection [a,a1,a2]
Last[%]
Block[{$RecursionLimit=1000},f= a]
RandomChoice[a,27]
Thread[a=NestWhileList[a!= a1>a!=a2[Element[a,aa]& Element[a1,aa]& Element[aa,a],Element[a,aa]!=Element[a1,aa]!=Element[a2,aa]&],a,27]]
a=Flatten[List[%]]
Thread[a1=NestWhileList[a1!= a1>b!=a2[Element[a1,aa]& Element[a1,aa]& Element[aa,a1],Element[a1,aa]!=Element[a1,aa]!=Element[a1,aa]&],a1,27]]
a1=Flatten[%]
Block[{$RecursionLimit=1000},c1 ]
c1={#&,a+b1-c1}
b1={a,a1+a}
Map[MatchQ[#,_Integer]&,b]
Pick[c1,b1]
Do[If[a1 a1 And Or >=a1,Print["a1 = ",a1],Throw[a]],{a1,d}]
Catch[Do[If[a2!= a And Or #3&,Print["a1 = ",a1],Throw[a1]],{a,d}]]
Directory[]
Export["aa.txt","aa"]
Import["aa.txt"]
a=Flatten[a]
b=Flatten[a1]
c=Flatten[a2]
d=Union[a,b,c]
s=Subtract[a1,a2]
Take[a1,"-s"]
Solve[aa->aa!= aa!= #& ,aa]
a={3,4,5,7,10,15,23,27}
a1={4,6,7,8,9,10,12,15,25}
a2={2,6,7,10,11,12,23,13,14,15,25}
While a<=a1!=a2 Take[Last[a]]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=minimadiferen%C3%A7acomum0007.jpg&userId=1147177Luis Felipe Massena Misiec2017-08-06T20:48:16Z[GIF] How Does That Work? (Hamiltonian cycle on the 5-cell)
http://community.wolfram.com/groups/-/m/t/1269759
![Hamiltonian cycle on the 5-cell][1]
**How Does That Work?**
Very much the same idea as [_Touch ’Em All_][2] and [_All Day_][3]: think of the vertices of the 5-cell as living in the 3-sphere, put congruent spheres at each vertex, move them along a Hamiltonian cycle on the 1-skeleton of the 5-cell, then stereographically project the whole picture to $\mathbb{R}^3$.
I really like how this specific perspective creates a bit of a visual illusion.
Here's the code (once again leaving out the definition of `ProjectedSphere[]`, which can be found [here][4]):
Stereo[{x1_, y1_, x2_, y2_}] := {x1/(1 - y2), y1/(1 - y2), x2/(1 - y2)}
smootheststep[t_] := -20 t^7 + 70 t^6 - 84 t^5 + 35 t^4;
fivecellvertices =
Normalize /@
{{1/Sqrt[10], 1/Sqrt[6], 1/Sqrt[3], 1},
{1/Sqrt[10], 1/Sqrt[6], 1/Sqrt[3], -1},
{1/Sqrt[10], 1/Sqrt[6], -2/Sqrt[3], 0},
{1/Sqrt[10], -Sqrt[3/2], 0, 0},
{-2 Sqrt[2/5], 0, 0, 0}};
DynamicModule[
{θ, pts = N[fivecellvertices], angle, pts3d, v, b,
cols = RGBColor /@ {"#F23557", "#22B2DA", "#3B4A6B"}},
angle = VectorAngle @@ pts[[;; 2]];
pts3d = Stereo /@ pts;
v = Normalize[pts3d[[2]] - pts3d[[1]]];
b = Normalize[NullSpace[{v, pts3d[[-1]]}][[1]]];
Manipulate[
θ = smootheststep[1 - t];
Graphics3D[
{Specularity[.8, 50],
Table[
ProjectedSphere[RotationMatrix[angle*θ, {pts[[i]], pts[[Mod[i + 1, Length[pts], 1]]]}].pts[[i]], .15],
{i, 1, Length[pts]}]},
Boxed -> False, PlotRange -> 3, ViewPoint -> v,
ViewVertical -> -pts3d[[-1]], ViewAngle -> π/5,
Background -> Darker[cols[[-1]]], ImageSize -> 540,
Lighting -> {{"Directional", cols[[1]], RotationMatrix[2 π θ, v].(b - v/2)},
{"Directional", cols[[2]], -RotationMatrix[2 π θ, v].(b + v/2)},
{"Ambient", Darker[cols[[-1]]]}}],
{t, 0, 1}]
]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=proj30q.gif&userId=610054
[2]: http://community.wolfram.com/groups/-/m/t/1263478
[3]: http://community.wolfram.com/groups/-/m/t/1265322
[4]: http://community.wolfram.com/groups/-/m/t/1260753Clayton Shonkwiler2018-01-21T03:56:47ZCustom activation function in Neural Network?
http://community.wolfram.com/groups/-/m/t/1263274
Hello! Is it possible to set user defined activation function for a layer in neural network?
If this feature is not yet part of WL, are there any plans for such an addition as it would be very helpful.narendra2018-01-10T20:39:53ZConditional subscript systems of equations
http://community.wolfram.com/groups/-/m/t/1268721
I'm new to mathematica and I'm working through some economics problems. I've read through a lot of documentation and books, but I'm having a hard time understanding how to get mathematica to do some basic formula solving. In the system of equations below, would it be possible to get mathematica to correctly imput the form of the last equation (c3, t+2), if the equations above them where already defined as functions? I tried looking up conditional subscript formating, but I couldn't figure out how to
1). Define Nst as a subscripts, conditional on S
2). Then, when s=3, to guess that it should equal the final equation
Apologies if I've somehow missed something basic about mathematica or posting on this forum. Thank you
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=mathforforum.jpg&userId=757094Greg Ferenstein2018-01-20T03:47:52Z[✓] Use the Absolute Time function with a list of dates/times?
http://community.wolfram.com/groups/-/m/t/1269723
Hello Wolfram community!
We are struggling to find a solution to the Absolute Time function. We would like to convert a list of dates (including the time of that day) into absolute time, but we always get an error message.
Do we need to do them all separately? If so, that would mean a lot of work for us...
Any help would be greatly appreciated!Joana Schenk2018-01-20T15:28:47ZImprove this process to model the intersections of the diffusion of sperm?
http://community.wolfram.com/groups/-/m/t/1268295
I am trying to make code modeling the intersections (defined by methods using integration) of the diffusion of sperm and egg graphs at all points in time (so more integration was used) with respect to different distances.
The derivation of this process should not matter, but rather my problem is that I have run this code for days to no avail.
Integrating over time for each graph gives the expected percentage of zygotes formed for each distance. My goal is to obtain these values and plot the results. Here is my code:
s[x_, y_, t_] = (1/(Sqrt[4*Pi*t])^3)*
E^((-(x + 0)^2 - (y + 0)^2)/(4*t));
e[x_, y_, t_, d_] = (1/(Sqrt[4*Pi*t])^3)*
E^((-(x + d)^2 - (y + d)^2)/(4*t));
f2D[sc_, t_] = N[(171.153*sc - 0.149*t + 31.334)/100];
xcoord = Table[g, {g, 1, 100, 9}]
upper[d_] :=
t /. First@
NSolve[N[(N[
Integrate[
If[s[x, y, t] > 0 &&
e[x, y, t, d] > 0, (e[x, y, t, d] + s[x, y, t])*
f2D[s[x, y, t], t],
0], {x, -\[Infinity], \[Infinity]}, {y, -\[Infinity], \
\[Infinity]}]])/(2*
N[Integrate[
1, {x, -\[Infinity], \[Infinity]}, {y, -\[Infinity], \
\[Infinity]}, {z, 0, s[x, y, t]}]])] == 0, t, Reals];
function =
N[Integrate[(N[
Integrate[
If[s[x, y, t] > 0 &&
e[x, y, t, d] > 0, (e[x, y, t, d] + s[x, y, t])*
f2D[s[x, y, t], t],
0], {x, -\[Infinity], \[Infinity]}, {y, -\[Infinity], \
\[Infinity]}]])/(2*
N[Integrate[
1, {x, -\[Infinity], \[Infinity]}, {y, -\[Infinity], \
\[Infinity]}, {z, 0, s[x, y, t]}]]), {t, 1, upper[d]}]]
ycoord = Table[function, {d, 1, 100, 9}]
sorted = Riffle[xcoord, ycoord];
coords = {First[#], Part[#, 2]} & /@ Split[sorted]
ListPlot[coords]
The first output for the x-coordinates were easily listed, but the next piece of code has not finished running.
It is important to mention that running the `function` on its own—albeit, with a specified distance—has outputted data for the integration over all times at that distance. Furthermore, the percentage of zygotes at a distance `d` is defined as the integration over the times from 1 to A where A represents the time where the probability of fertilization at time A = 0 (probability becomes negative after that).
Is there any way to yield results faster? Is there an error in my code to find the time A?
Any assistance would be highly appreciated!
EDIT: I added the full code (all equations denoted)Vinny Pagano2018-01-19T14:52:33ZWorld Death Rates Visualization
http://community.wolfram.com/groups/-/m/t/777884
A friend of mine pointed to a very interesting article regarding "the golden cohort", a slice of the UK population that is living longer and healthier than the groups both above and below their age.
http://www.bbc.com/news/uk-15024436
He also wanted to know if they US population did have a similar generation.
So I tried if I could replicate the study with Mathematica.
Version 10.3 has released the function MortalityData. It does cover many properties and parameters on the population, but the availability of data is somewhat restricted on the time interval.
Instead we could download the tables from the source that WRI used as base for MortalityData (www.mortality.org)
Let's graph the percent changes in the three year moving average of death rates.
(*Set up our own color scaling*)
color[x_]:=Piecewise[{{Darker@Red,x>=5},{Orange,x>=4},{Pink,x>=3},
{Yellow,x>=2},{Darker@Green,x>=1},{Green,x>=0},{Lighter@Blue,x>=-2},
{Blue,x>=-4},{Purple,x<=-4}}]
(*Define the plot legend to be used in our charts*)
scale=ArrayPlot[{Range[-5,5]},ColorFunction->color,ColorFunctionScaling->False,FrameTicks->{None,{{1.5,-4},{3.5,-2},{5.5,0},{6.5,1},{7.5,2},{8.5,3},{9.5,4},{10.5,5}}}];
fname=FileNameJoin[{$UserDocumentsDirectory,"death_rates.zip"}];
interval=3;
If[FileNames[fname]=={},URLSave["http://www.mortality.org/hmd/zip/by_statistic/death_rates.zip",fname,"Username"->"johndoe@gmail.com","Password"->"1234567890"]];
files=Cases[Import[fname,"FileNames"],a_/;StringMatchQ[a,"Mx_1x1\\"~~__]];
data=Import[fname,{files[[#]],"Data"}]&/@Range@Length@files;
countries=data[[All,1,1]];
deathChart[deathRateData_,title_,key_,interval_]:=Module[{data,years,ratio,ds,values,ma,dif,pct,yearTicks,revPct,fields={"Year","Age","Female","Male","Total"}},
Quiet[data=Flatten[StringSplit[#]&/@deathRateData[[4;;]],1];
data [[All,3;; ]]=ToExpression[data[[All,3;;]]];
years=ToExpression@Union[data[[All,1]]];
ratio=100/(Length@years-interval);
ds=Dataset[AssociationThread[fields,#]&/@data];
values=ds[GroupBy["Age"],GroupBy["Year"],Identity,key]//Values//Normal;
values=Flatten[Values[values[[#]]]/.$Failed->0.]&/@Range@Length@values;
ma=MovingAverage[values[[#]],interval]&/@Range@Length@values;
dif=Differences[ma[[#]]]&/@Range@Length@ma;
pct=Table[100dif[[i,j]]/ma[[i,j]],{i,100},{j,Length@dif[[1]]}]/.Indeterminate->0.;
pct=MovingAverage[pct[[#]],interval]&/@Range@Length@pct;
yearTicks={#-2,#+years[[interval]]}&/@Range[Length@years-interval,1,-10];
revPct=With[{len=Length@pct},pct[[len-(#-1)]]&/@Range@len];
Rasterize@Column[{MatrixPlot[revPct,ColorFunction->color,ColorFunctionScaling->False,Mesh->All,FrameTicks->{{#,100-#}&/@Range[0,100,5],yearTicks},AspectRatio->ratio,ImageSize->Ceiling[6(Max[#]-Min[#])&@years],PlotLabel->Style[title,Bold,Medium],FrameLabel->(Style[#,Bold,Medium]&/@{"Age","Year"})],scale},Alignment->Center]]]
Manipulate[deathChart[Extract[data,First[Position[countries,country]]],country<> " change in mortality rates (3 month avg) - " <> key,key,3],{country,countries},{key,{"Male","Female","Total"}},SynchronousUpdating->False]
![enter image description here][1]
Now let's look at some of the results.
France first, male population..
![enter image description here][2]
We can see during the 19th century how different epidemics/pandemics/crop failures would affect death rates across all generations, and even cause revolutions. Example, the crops failures and cholera outbreaks between 1829 and 1832 that catalyzed the june revolution of 1832 described in Les Miserables,.
We can also see the effect of major conflicts such as the franco-prussian war of 1870, WWI and WWII.
another interesting aspect is to see that generations that were born in a conflict, or disaster, have worse health than other generations. You can see the streaks of generation with higher death rates than younger and older cohorts and how this extends across time.
Overall we can see that the advances in medicine, agriculture and public health has allowed humankind to escape from the periodic waves of increased mortalities. We don't see the same kind of pattern after the late 50's
https://en.wikipedia.org/wiki/Diseases_and_epidemics_of_the_19th_century
https://en.wikipedia.org/wiki/List_of_epidemics
To the USA, male.
![enter image description here][3]
We can see the effect of WWII, Korea and Vietnam. Two oceans have isolated America of the ravages of war.
It is interesting to see an increase in deaths around 1968 for all generations.
Why is the same generation that had was affected in their young adulthood, affected again in the early 90s? Crack Epidemic? It is interesting to see that there is an uptick on the teenage group too during those years.
Is the blob around 2001-2008 the Iraq/Iran war?
Finally Russia - Male and Female
![enter image description here][4]
Is the substantial increase after 1990 due to the repercussions of the collapse of the Soviet Union? After a respite during the end of the 20th century, the numbers spiked again. What are the drivers?
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=winnie.gif&userId=78214
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=france-male.png&userId=78214
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=us.png&userId=78214
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=deathsv2.png&userId=78214Diego Zviovich2016-01-25T00:34:31ZCan a function know its own name?
http://community.wolfram.com/groups/-/m/t/1266955
Say I have a function:
test[x_] := Block[{x}, ToExpression["test" <> "State"]; testState = 67]
testState is a global that test can refer to to see its last state:
In[133]:= testState
Out[133]= 67
*Test* needs to be used repeatedly by renaming it *test1*, *test2*, etc.
So, can test1 know its own name?Eric Johnstone2018-01-17T14:36:44ZAvoid old issue with Limit[Abs[Sign[x*Sin[1/x]]],x->0] = 1 ?
http://community.wolfram.com/groups/-/m/t/1267696
BTW, this bug is still present in Mathematica 11.2, i.e. it claims that
Limit[Abs[Sign[x*Sin[1/x]]],x->0]
is equal to 1. But Maxima 5.41.0 correctly says that it is "undefined", i.e. doesn't exist. As for REDUCE, it cannot calculate this limit at all (and it fails to calculate correctly many other simple limits, like abs(sign(x)) when x->0).
The fundamental problem here is that Mathematica may be assuming that if a function f(x) (x->x0) has a limit y0 and function g(y) (y->y0) has a limit g0, then their composition g(f(x)) also has a limit when (x->x0) and it is equal to g0. But this is not true and the above quote from Zorich's textbook is a good counter-example. I think this is worth fixing in the future versions of the best symbolic manipulation software on this planet, which Mathematica certainly is.Tigran Aivazian2018-01-18T15:02:47ZWhat method does FindGraphCommunities use with Method -> "Centrality"?
http://community.wolfram.com/groups/-/m/t/1267979
[*Cross-posted to M.SE*](https://mathematica.stackexchange.com/q/164057/12)
----
I would like to know what method `FindGraphCommunities` uses with the option `Method -> "Centrality"` when given an edge-weighted graph.
Based on the name of the `Method` option value, I think it is not unreasonable to assume that it uses the Girvan–Newman algorithm, described in dx.doi.org/10.1073/pnas.122653799 and also in the review paper https://arxiv.org/abs/0906.0612 (see section V.A).
This method constructs a hierarchical clustering tree by repeatedly removing the graph edge with the highest edge betweenness.
This does not appear to be the case, as evidenced by the following example:
g = Graph3D[{1 <-> 2, 2 <-> 3, 3 <-> 1, 4 <-> 5, 5 <-> 6, 6 <-> 4, 1 <-> 4, 2 <-> 5, 3 <-> 6},
EdgeWeight -> {1, 1, 1, 1, 1, 1, 5, 5, 5}]
FindGraphCommunities[g, Method -> "Centrality"]
(* {{1, 4}, {2, 5}, {3, 6}} *)
This result couldn't have been obtained with a direct application of the Girvan–Newman algorithm because the edges `1 <-> 4, 2 <-> 5, 3 <-> 6` have the highest betweenness, therefore they are removed first.
EdgeBetweennessCentrality[g]
(* {4., 4., 4., 4., 4., 4., 6., 6., 6.} *)
----
So far I was able to get the following information from WRI: `FindGraphCommunities` implements methods from the paper https://arxiv.org/abs/0906.0612 However, I do not know which specific method is being used in this particular case, and how Mathematica arrives to this result. The problem of community detection is not precisely defined in network science. There are many different methods which may be reasonable in different situations. Therefore I couldn't possibly use such a result in a published paper without knowing how Mathematica obtained it.
I do not need to know *how* Mathematica computes e.g. eigenvalues to understand what an eigenvalue is, or even to verify that the result it gave me is correct. The situation with `FindGraphCommunities` is different: *what* it computes and *how* it computes it are basically the same question.
While I tagged this as `implementation-details` on M.SE, I want to emphasize that this question is really about *what this function is doing at all*, not how it does it. Of what use is such a function if users don't know what it really does?
----
If I am misunderstanding something, please do correct me.Szabolcs Horvát2018-01-19T13:11:50ZEducational plot for cellular automaton
http://community.wolfram.com/groups/-/m/t/1268198
Here is an idea to display a [CellularAutomaton][1] evolution where every updated cell shows the neighborhood above it. This might be helpful when explaining to someone how it works.
![plot of rule 30 for 4 steps][2]
ECAPlot[history_, opts___] :=
With[{l = Length[history]}, Graphics[{EdgeForm[Gray],
MapIndexed[{GrayLevel[1 - #], Rectangle[{#2[[2]] - 1, l - #2[[1]]}]} &, history, {2}],
MapIndexed[Table[{GrayLevel[1 - #[[1, i]]],
Rectangle[{#2[[2]] - 1 + .2 (i), l - #2[[1]] - 1 + .4}, {#2[[2]] - 1 + .2 (i + 1), l - #2[[1]] - 1 + .6}]}, {i, 3}] &,
RotateRight /@ Most[Partition[history, {2, 3}, 1, 1]], {2}]}, opts]]
The update for each cell depends on the three cells above it, one to the left, one above and one to the right. The rule for the update stays the same. There are only eight cases for a rule so there are 256=2^8 rules. For more information see Wolfram's [New Kind of Science][3]. There are other ways for viewing rules like [RulePlot][4] but there should be more modern ways for helping explain how these simple rules work.
With the above code, the picture is from
ECAPlot[CellularAutomaton[30, {{1}, 0}, 4]]
[1]: http://reference.wolfram.com/language/ref/CellularAutomaton.html
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=eca-edu-plot.png&userId=23275
[3]: http://www.wolframscience.com/nks/
[4]: http://reference.wolfram.com/language/ref/RulePlot.htmlTodd Rowland2018-01-19T14:47:15ZUse the numbers found in an optimization problem somewhere else?
http://community.wolfram.com/groups/-/m/t/1268030
Hello all,
Let's say we solve maximization problem and create a table for a specific range. An example:
c1 = Table[NMaximize[{(x*y - y^2 + x - x^2)*a/2, 0 <= y <= x <= 1, a*(1 - y) <= 1}, {x, y}], {a, 1, 6, 0.1}]
Now resulting table have elements in a form such:
{0.166667, {x -> 0.666667, y -> 0.333333}
In order to solve another problem, I need to use these x and y values. How can I call them in a different place?
Best, Ovunc
p.s. I took the table to Excel, created three rows. I imported the Excel file into Mathematica, but this time I cannot convert it to the matrix form I am interested in.Ovunc Yilmaz2018-01-18T19:59:48ZHome Blood Pressure Monitoring
http://community.wolfram.com/groups/-/m/t/1265408
On November 13th, 2017 the American College of Cardiology and American Heart Association released a massive document centered on the prevention, detection, evaluation and management of high blood pressure in adults.
http://hyper.ahajournals.org/content/early/2017/11/10/HYP.0000000000000065
New blood pressure categories were established:
![enter image description here][1]
While the decision about when to modify lifestyle habits and/or introduce or change medications is best left to discussions between each person and their family physician / cardiologist, there is no reason we can't rely on our favorite computing platform - Mathematica - to help us organize data typically collected through home blood pressure monitoring.
I currently use a blood pressure application called "Blood Pressure Log - My Diary" (via GooglePlay) written by Dr. Tomasz Jan Zlamaniec to record my sphygmomanometer readings - specially my systolic & diastolic blood pressure values, as well as heart rate. The application automatically records the date and time of the data entered. It is a simple matter of exporting the data (csv, xlsx format) to be organized and summarized by Mathematica. The application exports 5 columns of data, including date, time (in 24 hour format), systolic bp, diastolic bp, heart rate (in beats per minute).
Importing the data from the application into Mathematica looks as follows:
mydata = Drop[
Flatten[Import["C:\\Users\\Todd's PC\\Desktop\\Todd BP scrubbed.xlsx",
"Data"], 1], None, {2}]
![enter image description here][2]
You'll note that Mathematica automatically collapses the date and time into a single DateObject[], which is why we are left with 4 columns of data instead of the initial 5 exported from the blood pressure application. (Mathematica does preserve the 5 column data structure by inserting data that is not useful to me, so I Drop it after the import.)
I've created some code (notebook attached & printed below) that will produce graphical and statistical output simply by sending <mydata> to a function called <bpdashboard>.
bpdashboard[mydata]
Tab 1 (Blood Pressure): A ListPlot of your personal systolic (x-axis) and diastolic (y-axis) values. Data points are wrapped in tooltip and will report their values when you place your cursor over them. The data is color coded according to the time of day the value was recorded. Morning is defined as 0100 to 1159 hours. Afternoon 1200 to 1759 hours and evening from 1800 to 2459 hours.
![enter image description here][3]
Tab 2 (Pulse Pressure): A DateListPlot of your pulse pressure. Pulse pressure is the difference between systolic and diastolic values. Normal pulse pressure is considered 40mmHg. Note that data is displayed in a stacked format to make it easier to see morning, afternoon, and evening data on the same plot.
![enter image description here][4]
Tab 3: A DateListPlot of your mean arterial pressure. Mean arterial pressure is defined as the average blood pressure in a patient's arteries during one cardiac cycle. MAP is generally considered normal in the 60 - 110 mmHg range. As in Tab 2, the data is plotted in a stacked format.
![enter image description here][5]
Tab 4: A statistical summary reporting many self explanatory vital statistics. SD = standard deviation; bpm = beats per minute; MAP = mean arterial pressure
![enter image description here][6]
My goal in creating such a program is to be able to produce monthly status reports on my cardiovascular health, print the data as desired, and take the information along to office visits as necessary. Feel free to use and modify for your own purposes.
Wishing everyone good cardiovascular health in 2018!
------------------------------------------------------------------------------------------------
## bpdashboard code:
The code for bpdashboard is self contained inside a Module for the sake of clarity and organization. Upon execution, bpdashboard organizes the blood pressure data sent to it, and creates a simple user interface using TabView to facilitate graphical interpretation of the data as well as providing a statistical summary of various metrics computable from blood pressure data. Interested readers will note that mean arterial pressure (MAP) is calculated through the use of a formula originally published here:
https://www.jstage.jst.go.jp/article/ahs1995/14/6/14_6_293/_article
bpdashboard[mydata_] :=
Module[{afterdiasbpminmax, afterheartrateminmax, aftermeandiasbp,
aftermeanheartrate, aftermeanmap, aftermeanpulpre, aftermeansysbp,
afternoonbp, afternoondata, afternoonpos, afterstdevdiasbp,
afterstdevheartrate, afterstdevmap, afterstdevpulpre,
afterstdevsysbp, aftersysbpminmax, bpplot, diasbp,
evendiasbpminmax, evenheartrateminmax, eveningbp, eveningdata,
eveningpos, eveningstdevdiasbp, evenmeandiasbp, evenmeanheartrate,
evenmeanmap, evenmeanpulpre, evenmeansysbp, evenstdevheartrate,
evenstdevmap, evenstdevpulpre, evenstdevsysbp, evensysbpminmax,
globaldiasbpminmax, globalheartrateminmax, globalmeandiasbp,
globalmeanheartrate, globalmeanmap, globalmeanpulpre,
globalmeansysbp, globalminmaxdiasbp, globalminmaxheartrate,
globalminmaxsysbp, globalstdevdiasbp, globalstdevheartrate,
globalstdevmap, globalstdevpulpre, globalstdevsysbp,
globalsysbpminmax, heartrate, mapafternoon, mapevening, mapmorn,
mapplot, meanarterialpressure, mornbp, morndata, morndiasbpminmax,
mornheartrateminmax, mornmeandiasbp, mornmeanheartrate,
mornmeanmap, mornmeanpulpre, mornmeansysbp, mornpos,
mornstdevdiasbp, mornstdevheartrate, mornstdevmap, mornstdevpulpre,
mornstdevsysbp, mornsysbpminmax, ppplot, pulpresafter,
pulpreseven, pulpresmorn, samplehrs, samplesize, statreport, sysbp},
samplesize = Length[mydata];(* number of data points /
blood pressure measurements *)
Length[Union[DateValue[mydata[[All, 1]], "Day"]]];(*
number of days in dataset *)
samplehrs = DateValue[mydata[[All, 1]], "Hour"];(*
time of day (hour units) measurements taken *)
mornpos = Flatten[Map[Position[samplehrs, #] &, Range[11]], 1];(*
position of morning data; morning from 0100 to 1159 hours *)
afternoonpos =
Flatten[Map[Position[samplehrs, #] &, Range[12, 17]], 1];(*
position of afternoon data; afternoon from 1200 to 1759 hours *)
eveningpos =
Flatten[Map[Position[samplehrs, #] &, Range[18, 24]], 1];(*
position of evening data; evening from 1800 to 2459 hours *)
meanarterialpressure[{sysbp_, diasbp_, heartrate_}] := Module[{map},
map =
diasbp + 0.01*Exp[4.14 - (40.74/heartrate)]*(sysbp - diasbp)];
morndata = Extract[mydata, mornpos];
afternoondata = Extract[mydata, afternoonpos];
eveningdata = Extract[mydata, eveningpos];
mornbp = MapThread[List, {morndata[[All, 2]], morndata[[All, 3]]}];
afternoonbp =
MapThread[List, {afternoondata[[All, 2]], afternoondata[[All, 3]]}];
eveningbp =
MapThread[List, {eveningdata[[All, 2]], eveningdata[[All, 3]]}];
pulpresmorn =
MapThread[
List, {morndata[[All,
1]], (morndata[[All, 2]] - morndata[[All, 3]])}];(*
pulse pressure morning *)
pulpresafter =
MapThread[
List, {afternoondata[[All,
1]], (afternoondata[[All, 2]] - afternoondata[[All, 3]])}];(*
pulse pressure afternoon *)
pulpreseven =
MapThread[
List, {eveningdata[[All,
1]], (eveningdata[[All, 2]] - eveningdata[[All, 3]])}];(*
pulse pressure evening *)
globalsysbpminmax = MinMax[mydata[[All, 2]]];
globaldiasbpminmax = MinMax[mydata[[All, 3]]];
mornsysbpminmax = MinMax[morndata[[All, 2]]];
morndiasbpminmax = MinMax[morndata[[All, 3]]];
aftersysbpminmax = MinMax[afternoondata[[All, 2]]];
afterdiasbpminmax = MinMax[afternoondata[[All, 3]]];
evensysbpminmax = MinMax[eveningdata[[All, 2]]];
evendiasbpminmax = MinMax[eveningdata[[All, 3]]];
globalheartrateminmax = MinMax[mydata[[All, 4]]];
mornheartrateminmax = MinMax[morndata[[All, 4]]];
afterheartrateminmax = MinMax[afternoondata[[All, 4]]];
evenheartrateminmax = MinMax[eveningdata[[All, 4]]];
globalmeansysbp = Mean[mydata[[All, 2]]];
globalstdevsysbp = StandardDeviation[mydata[[All, 2]]];
globalmeandiasbp = Mean[mydata[[All, 3]]];
globalstdevdiasbp = StandardDeviation[mydata[[All, 3]]];
mornmeansysbp = Mean[morndata[[All, 2]]];
mornstdevsysbp = StandardDeviation[morndata[[All, 2]]];
mornmeandiasbp = Mean[morndata[[All, 3]]];
mornstdevdiasbp = StandardDeviation[morndata[[All, 3]]];
aftermeansysbp = Mean[afternoondata[[All, 2]]];
afterstdevsysbp = StandardDeviation[afternoondata[[All, 2]]];
aftermeandiasbp = Mean[afternoondata[[All, 3]]];
afterstdevdiasbp = StandardDeviation[afternoondata[[All, 3]]];
evenmeansysbp = Mean[eveningdata[[All, 2]]];
evenstdevsysbp = StandardDeviation[eveningdata[[All, 2]]];
evenmeandiasbp = Mean[eveningdata[[All, 3]]];
eveningstdevdiasbp = StandardDeviation[eveningdata[[All, 3]]];
globalmeanheartrate = Mean[mydata[[All, 4]]];
globalstdevheartrate = StandardDeviation[mydata[[All, 4]]];
mornmeanheartrate = Mean[morndata[[All, 4]]];
mornstdevheartrate = StandardDeviation[morndata[[All, 4]]];
aftermeanheartrate = Mean[afternoondata[[All, 4]]];
afterstdevheartrate = StandardDeviation[afternoondata[[All, 4]]];
evenmeanheartrate = Mean[eveningdata[[All, 4]]];
evenstdevheartrate = StandardDeviation[eveningdata[[All, 4]]];
globalmeanpulpre =
Mean[Flatten[{pulpresmorn[[All, 2]], pulpresafter[[All, 2]],
pulpreseven[[All, 2]]}]];
globalstdevpulpre =
StandardDeviation[
Flatten[{pulpresmorn[[All, 2]], pulpresafter[[All, 2]],
pulpreseven[[All, 2]]}]];
mornmeanpulpre = Mean[pulpresmorn[[All, 2]]];
mornstdevpulpre = StandardDeviation[pulpresmorn[[All, 2]]];
aftermeanpulpre = Mean[pulpresafter[[All, 2]]];
afterstdevpulpre = StandardDeviation[pulpresafter[[All, 2]]];
evenmeanpulpre = Mean[pulpreseven[[All, 2]]];
evenstdevpulpre = StandardDeviation[pulpreseven[[All, 2]]];
globalminmaxsysbp = MinMax[mydata[[All, 2]]];
globalminmaxdiasbp = MinMax[mydata[[All, 3]]];
globalminmaxheartrate = MinMax[mydata[[All, 4]]];
mapmorn =
MapThread[
List, {morndata[[All, 1]],
Map[meanarterialpressure[#] &, morndata[[All, 2 ;; 4]]]}];(*
mean arterial pressure in the morning *)
mapafternoon =
MapThread[
List, {afternoondata[[All, 1]],
Map[meanarterialpressure[#] &, afternoondata[[All, 2 ;; 4]]]}];(*
mean arterial pressure in the afternoon *)
mapevening =
MapThread[
List, {eveningdata[[All, 1]],
Map[meanarterialpressure[#] &, eveningdata[[All, 2 ;; 4]]]}]; (*
mean arterial pressure in the evening *)
globalmeanmap =
Mean[Flatten[{mapmorn[[All, 2]], mapafternoon[[All, 2]],
mapevening[[All, 2]]}]];
globalstdevmap =
StandardDeviation[
Flatten[{mapmorn[[All, 2]], mapafternoon[[All, 2]],
mapevening[[All, 2]]}]];
mornmeanmap = Mean[mapmorn[[All, 2]]];
mornstdevmap = StandardDeviation[mapmorn[[All, 2]]];
aftermeanmap = Mean[mapafternoon[[All, 2]]];
afterstdevmap = StandardDeviation[mapafternoon[[All, 2]]];
evenmeanmap = Mean[mapevening[[All, 2]]];
evenstdevmap = StandardDeviation[mapevening[[All, 2]]];
bpplot =
ListPlot[{Tooltip[mornbp], Tooltip[afternoonbp],
Tooltip[eveningbp]},
PlotLegends ->
Placed[Map[
Style[#, FontSize -> 16] &, {"morning", "afternoon",
"evening"}], Top],
PlotRange -> Full,
ImageSize -> Large,
Frame -> True,
FrameLabel -> {{Style["Diastolic BP (mm Hg)", FontSize -> 12],
Rotate[
Style[StringJoin[
Insert[Map[ToString[#] &,
DateValue[mydata[[1, 1]], {"MonthNameShort", "Year"}]],
" ", 2]], FontSize -> 12], 180 Degree]},
{Style["Systolic BP (mm Hg)", FontSize -> 12], None}},
Epilog -> {{Red, Dashed, InfiniteLine[{{120, 0}, {120, 10}}]},
{Red, Dashed, InfiniteLine[{{0, 80}, {10, 80}}]}}];
ppplot = DateListPlot[{pulpresmorn, pulpresafter, pulpreseven},
PlotLayout -> "Stacked",
PlotLegends ->
Placed[Map[
Style[#, FontSize -> 16] &, {"morning", "afternoon",
"evening"}], Top],
PlotRange -> Full,
ImageSize -> Large,
Frame -> True,
FrameLabel -> {{Style["Pulse Pressure (mm Hg)", FontSize -> 12],
None},
{Style[DateValue[mydata[[1, 1]], "Year"], FontSize -> 12],
None}}];
mapplot = DateListPlot[{mapmorn, mapafternoon, mapevening},
PlotLayout -> "Stacked",
PlotLegends ->
Placed[Map[
Style[#, FontSize -> 16] &, {"morning", "afternoon",
"evening"}], Top],
PlotRange -> Full,
ImageSize -> Large,
Frame -> True,
FrameLabel -> {{Style["Mean Arterial Pressure (mm Hg)",
FontSize -> 12], None},
{Style[DateValue[mydata[[1, 1]], "Year"], FontSize -> 12],
None}}];
statreport = TextGrid[
{{"", Style["Global", Bold], Style["Morning", Bold],
Style["Afternoon", Bold], Style["Evening", Bold]},
{"Sample Size (n)", samplesize, Length[morndata],
Length[afternoondata], Length[eveningdata]},
{""},
{"Mean Systolic BP (SD) (mmHg)",
Row[{Round[globalmeansysbp], " (", Round[globalstdevsysbp],
")"}], Row[{Round[mornmeansysbp], " (", Round[mornstdevsysbp],
")"}],
Row[{Round[aftermeansysbp], " (", Round[afterstdevsysbp], ")"}],
Row[{Round[evenmeansysbp], " (", Round[evenstdevsysbp], ")"}]},
{""},
{"Mean Diastolic BP (SD) (mmHg)",
Row[{Round[globalmeandiasbp], " (", Round[globalstdevdiasbp],
")"}],
Row[{Round[mornmeandiasbp], " (", Round[mornstdevdiasbp], ")"}],
Row[{Round[aftermeandiasbp], " (", Round[afterstdevdiasbp],
")"}],
Row[{Round[evenmeandiasbp], " (", Round[eveningstdevdiasbp],
")"}]},
{""},
{"Mean Pulse Pressure (SD) (mmHg)",
Row[{Round[globalmeanpulpre], " (", Round[globalstdevpulpre],
")"}],
Row[{Round[mornmeanpulpre], " (", Round[mornstdevpulpre], ")"}],
Row[{Round[aftermeanpulpre], " (", Round[afterstdevpulpre],
")"}],
Row[{Round[evenmeanpulpre], " (", Round[evenstdevpulpre], ")"}]},
{""},
{"Mean MAP (SD) (mmHg)",
Row[{Round[globalmeanmap], " (", Round[globalstdevmap], ")"}],
Row[{Round[mornmeanmap], " (", Round[mornstdevmap], ")"}],
Row[{Round[aftermeanmap], " (", Round[afterstdevmap], ")"}],
Row[{Round[evenmeanmap], " (", Round[evenstdevmap], ")"}]},
{""},
{"Mean Heart Rate (SD) (bpm)",
Row[{Round[globalmeanheartrate], " (",
Round[globalstdevheartrate], ")"}],
Row[{Round[mornmeanheartrate], " (", Round[mornstdevheartrate],
")"}],
Row[{Round[aftermeanheartrate], " (",
Round[afterstdevheartrate], ")"}],
Row[{Round[evenmeanheartrate], " (", Round[evenstdevheartrate],
")"}]},
{""},
{"Min & Max Systolic BP (mmHg)", globalminmaxsysbp,
mornsysbpminmax, aftersysbpminmax, evensysbpminmax},
{""},
{"Min & Max Diastolic BP (mmHg)", globalminmaxdiasbp,
morndiasbpminmax, afterdiasbpminmax, evendiasbpminmax},
{""},
{"Min & Max Heart Rate (bpm)", globalheartrateminmax,
mornheartrateminmax, afterheartrateminmax, evenheartrateminmax}
},
Spacings -> {2, Automatic}
];
TabView[{"Blood pressure" -> bpplot, "Pulse pressure" -> ppplot,
"Mean arterial pressure" -> mapplot,
"Statistical summary" -> statreport}]
]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=categorysnip.JPG&userId=99116
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=importsnip.JPG&userId=99116
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=bpsnip.JPG&userId=99116
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=pulsepressuresnip.JPG&userId=99116
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=mapsnip.JPG&userId=99116
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=statsnip.JPG&userId=99116
[7]: https://www.jstage.jst.go.jp/article/ahs1995/14/6/14_6_293/_articleTodd Allen2018-01-13T21:09:06ZDynamicModule does not assign properly in CDF but works well in NB?
http://community.wolfram.com/groups/-/m/t/1268205
I have made a small interactive module based on the dynamic module from the Mathematica help files. It runs well in NB format (full version), but fails in CDF Player. The section from the help file is:
Panel[DynamicModule[{f = Sin[x]},
Column[{InputField[Dynamic[f]], Dynamic[f],
Dynamic[Plot[f, {x, -5, 5}]]}]]]
This is not exactly how I use it, but already this version does not run for any function other than a number, x or -x in CDF Player (or simulation). The Dynamic[f] field is not updated.
Is there a way to make it CDF compatible and keep the general nature of plotting any function?
Thanks!Wolfgang Frey2018-01-19T02:41:33Z[✓] Solve problem with PDF and discrete variates?
http://community.wolfram.com/groups/-/m/t/1264375
Can you help me understand why these two plots differ? It seems like in first case variate suddenly stopped being discrete
d1 = TransformedDistribution[x + x, x\[Distributed]DiscreteUniformDistribution[{1,6}]];
DiscretePlot[PDF[d1, {a}], {a,0,15}]
d2 = TransformedDistribution[x + x, {x\[Distributed]DiscreteUniformDistribution[{1,6}], y\[Distributed]DiscreteUniformDistribution[{1,6}]}];
DiscretePlot[PDF[d2, {b}], {b,0,15}]
Thank you.Michael Kilburn2018-01-12T10:46:35ZDoes WolframTones have an API? http://tones.wolfram.com
http://community.wolfram.com/groups/-/m/t/1268075
Trying to use WolframTones for a possible projectCharles Blake2018-01-19T01:56:17ZAitchison and angular distances for votes and seats
http://community.wolfram.com/groups/-/m/t/1267872
The following is a notebook in the cloud (1 MB), that one can best download and run on the desktop (see the browser in the lower right). It has initialisation cells for two small packages.
https://www.wolframcloud.com/objects/thomas-cool/Voting/2018-01-18-Aitchison.nb
Readers who recently looked at the Brexit discussion will find the topic familiar, see
http://community.wolfram.com/groups/-/m/t/1221950
The summary of the notebook is:
Votes and seats satisfy only two of seven criteria for application of the Aitchison distance. Vectors of votes and seats, say for elections for political parties the House of Representatives, can be normalised to 1 or 100%, and then have the outward appearance of compositional data. The Aitchison geometry and distance for compositional data then might be considered for votes and seats too. However, there is an essential zero when a party gets votes but doesn't gain a seat, and a zero gives an undefined logratio. In geology, changing from weights to volumes affects the percentages but not the Aitchison distance. For votes and seats there are no different scales or densities per party component however, and thus reportioning (perturbation) would be improper. Another key issue is subcompositional dominance. For votes {10, 20, 70} and seats {20, 10, 70} it is essential that we consider three parties. For a disproportionality measure we would value it positively that there is a match on 70. The Aitchison distance looks at the ratio {10, 20, 70} / {20, 10, 70} = {1/2, 2, 1} and then neglects a ratio equal to 1. In this case it essentially compares the subcompositions, i.e. votes {10, 20} and seats {20, 10}, rescales to {1/3, 2/3} and {2/3, 1/3}, and finds high disproportionality. This means that it essentially looks at a two party outcome instead of a three party outcome. It follows that votes and seats are better served by another distance measure. Suggested is the angular distance and the Sine-Diagonal Inequality / Disproportionality (SDID) measure based upon this. Users may of course apply both the angular and the Aitchison measures while being aware of the crucial differences in properties.
NB. This discussion forms part of a larger framework given most recently by my other paper: "One woman, one vote. Though not in the USA, UK and France". My diagnosis is that "political science on electoral systems" is still in the Humanities and pre-science, notably by relying more upon common language instead of sharp definitions that are relevant for empirics. On the other hand, there are also mathematicians who deal with their definitions abstractly, without a proper grounding in empirical research. My invitation to empirical researchers is to help make a difference, notably in re-engineering the theory on electoral systems.Thomas Colignatus2018-01-18T19:58:05Z[✓] Has the neural network palette vanished?
http://community.wolfram.com/groups/-/m/t/1267638
HI
I've been looking into Mathematica's support for neural networks, and especially the neural network palette. I can't seem to activate it as described in the online documentation. Do I need an extra package? The documentation says load the NeuralNetwork package with <<NeuralNetworks`and the palette should appear in the palette menu, but it doesn't.Nicholas Walton2018-01-18T11:42:37Z[✓] Turn on dynamic state selection?
http://community.wolfram.com/groups/-/m/t/1267239
In my build log I keep getting this error:
> Notification: Forcing static selection of states. If this leads to problems during simulation turn on dynamic state selection.
Is this a setting in SystemModeler, or do I just need to set `stateSelect` correctly?
While I'm posting, the more critical error that I'm getting is
> Internal error: DeriveMC.differentiateExpTime: error for expression CALL <myFunction>
I added `stateSelect = StateSelect.avoid` to a couple variables and that helped some, but when "myFunction" becomes less linear the build fails.
Thanks, EricEric Smith2018-01-17T19:31:16Z[✓] Output a Table as a Column?
http://community.wolfram.com/groups/-/m/t/1266354
Hallo!
I have a problem.
The code
Clear@"Global`*" (*Speicher löschen*)
test1[k_] = k;
test2[n_] = n;
text = "abc";
myrow[y_] = y;
mycolumn[x_] = x;
mycell[k_, n_] :=
ToString@myrow[n] <> " " <> ToString@mycolumn[k] <> " " <>
ToString@test1[k] <> " " <> ToString@test2[n] <> " " <>
ToString@text
list2 = Table[mycell[k, n], {k, 1, 2}, {n, 1, 3}]
Export["Test.txt", list2, "Table"]
gives me a txt-file with
1 1 1 1 abc 2 1 1 2 abc 3 1 1 3 abc
1 2 2 1 abc 2 2 2 2 abc 3 2 2 3 abc
How can I export a textfile which contains the same stuff rowwise?
That means:
1 1 1 1 abc
2 1 1 2 abc
3 1 1 3 abc
1 2 2 1 abc
2 2 2 2 abc
3 2 2 3 abc
Do you have any idea?
Thanks a lot!cis cis2018-01-16T23:39:23ZSingularity in NDSolve?
http://community.wolfram.com/groups/-/m/t/1267279
Hi, I am trying to plot the angles of a spherical pendulum fixed to a oscillating cart. I have derived the equations of motion, when I try to solve the equations using "NDSolve", following error occurs:
> `NDSolve::ndsz: At t == 0.1374350849846401`, step size is effectively zero; singularity or stiff system suspected.`
Have you got an idea?
(*Equations of motion for spherical pendulum fixed to oscillating cart*)
Remove[x, L, w , A]
(*Define equations of motion*)
eq1 = θ''[t] - ρ'[t]^2*Sin[θ[t]]*Cos[ρ[t]] - x''[t]/L*Cos[θ[t]]*Cos[ρ[t]] - (g*Sin[θ[t]])/L;
eq2 = L*x''[t]*Sin[θ[t]]*Sin[ρ[t]] - L^2*Sin[θ[t]]*(ρ''[t]*Sin[ρ[t]] + 2*ρ'[t]^2*Cos[ρ[t]]);
eq3 = -A*w^2*Cos[w*t] - x''[t];
(*x is the cart-position, θ and ρ the angles of the pendulum*)
(*Give numerical values for constants*)
A = 1;
g = 9.81;
L = 1;
w = 7;
(*Solve the equations using NDSOlve*)
sol = NDSolve[{eq1 == 0, eq2 == 0, eq3 == 0, θ[0] == 1, θ'[0] == 0,
ρ[0] == 1, ρ'[0] == 0, x[0] == 0, x'[0] == 0}, {θ, ρ}, {t, 0, 10}];
Plot[{Evaluate[θ[t] /. sol], Evaluate[ρ[t] /. sol]}, {t, 0, 10}]Jonas Hamp2018-01-18T09:40:25Z[✓] Extract the boundary points of an image using Wolfram Mathematica?
http://community.wolfram.com/groups/-/m/t/1266525
Hi, Currently, I am dealing with problems related to images. My intention is to convert an image to binary image and extract the boundary outline of the image to get the coordinates of the boundary image. Through Wolfram Mathematica, we can use the built-in function "binarize" to convert the image to binary image. Further steps to extract the boundary points through Wolfram Mathematica built-in function is not applicable. Is there any built-in function exist to extract the boundary outline points? For my concern, there is a "corner detection" but I could not find the built-in function for binary image outline extraction? Is there any way to extract the binary outline using Wolfram Mathematica? Here is an example of what I want to extract
## Original
![enter image description here][1]
## Extracted Boundary image
![enter image description here][2]
I want to get the boundary points and image as above. Can anyone help me?
Thank you in advance for your time
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Originalimage.JPG&userId=1266510
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ExtractedBoundaryimage.JPG&userId=1266510Nur Soffiah2018-01-16T08:53:22ZPlay Canon with Mathematica
http://community.wolfram.com/groups/-/m/t/1247481
I'm a Mathematica novice, so i think there is a lot of space to improve the code.
Here is [Youtube Link][1].Hopefully you like it.
First I use the Bach's manuscript as the music score, but the output sound is chaos around the middle part.This score fit to play with the instrument, obviously not Mathematica.
![Bach's manuscript][2]
After posting this awful version to my Weibo, my friend told me there is a [Canon played by Matlab][3], it's so amazing, the most important its score suits for playing with software, so i decided to translate this score from Matlab to Mathematica.
## Matlab code ##
There are 3 parts in Matlab code.
1.First, tell the computer how to make certain sounds.
There is a part of the code in Matlab
(I'm a Chinese student, hopefully my poor English didn't confuse you. I will attach some concepts' wikilink, sorry about that)
% 1/4 notes
do0f = mod4.*cos(2*pi*ScaleTable(21)*f0*t4);
re0f = mod4.*cos(2*pi*ScaleTable(22)*f0*t4);
mi0f = mod4.*cos(2*pi*ScaleTable(23)*f0*t4);
% 1/8 notes
fa0e = mod8.*cos(2*pi*ScaleTable(1)*f0*t8);
so0e = mod8.*cos(2*pi*ScaleTable(2)*f0*t8);
la0e = mod8.*cos(2*pi*ScaleTable(3)*f0*t8);
% 1/16 notes
fa0s = mod16.*cos(2*pi*ScaleTable(1)*f0*t16);
so0s = mod16.*cos(2*pi*ScaleTable(2)*f0*t16);
la0s = mod16.*cos(2*pi*ScaleTable(3)*f0*t16);
For clear to see, I just pick few notes information
i.$\frac{1}{4}$,$\frac{1}{8}$,$\frac{1}{16}$means [the relative duration of a note][4](https://en.wikipedia.org/wiki/Note_value), the duration of Quarter note is twice that of Eighth note, the duration of 8th note is twice that of 16th note. In the Matlab code, the duration depends on $t4,t8, or\space t16$
ii.Obviously, "do0f" means the note's tone. If you plot the the curve of middle A, it will be like that
![Middle A][5]
Middle A's frequency "f" is 440Hz. In the Matlab code, the frequency depends on "$ScaleTable(\space)\times f0$"
iii.mod is a modification function, it makes notes sound more soft. the number behind "mod" means it's duration
![mod*Middle A][6]
So the Matlab code looks more clear! It becomes$$notename=mod4\times cos(2\pi f t)$$
This the way how to make sounds in Matlab.
2.Second, tell the computer musical score
This part is easy to understand, just input the score.
% Base Melody
cello = [do1f do1f so0f so0f la0f la0f mi0f mi0f... fa0f fa0f do0f do0f fa0f fa0f so0f so0f];......
% Long Melody
violin = [mi2f mi2f re2f re2f do2f do2f ti1f ti1f... la1f la1f so1f so1f la1f la1f ti1f ti1f ......
3.Third, arrange the different instruments' sequence
Canon is an very interesting music style, you just need to put the same melody at 3 different time points, and done! (I know I didn't explain it clearly, you can see [Canon's wiki link][7])
It looks beautiful in code
% violin1
v1 = [blkblock violin blkblock blkblock];
% violin2
v2 = [blkblock blkblock violin blkblock];
% violin3
v3 = [blkblock blkblock blkblock violin];
% Combination
s = c1+v1+v2+v3;
sound(s,fs);
## Translate to Mathematica ##
We get all information about all notes and musical score, but it's Matlab code, not Mathematica, we need use Mathematica code translate it.(The Mathematica file at the bottom of the article, it's a little bit long, so I decided not to paste it here)
1. First, make the association between the note name and sound respectively in Mathematica. The output should be like this. I named this association "nametosoundass", remember this name.
![Note to sound association][8]
2.Next, we should get the list of sequence of every instrument should be play.
i.Input the raw sequence in Matlab to Mathematica, as you can see, there are many characters we don't want to get, such as "...", "%%", return and whitespace
cellonoteinfo =
"do1f do1f so0f so0f la0f%% la0f mi0f mi0f...fa0f%% fa0f do0f do0f fa0f \n
fa0f so0f so0f";
ii.Define a function to delete these unexpected characters
infotonote[info_] :=
StringPartition[StringJoin@StringCases[info, _?LetterQ | _?DigitQ],
4];
iii.Get the sequence
In[1]:= cellonote = infotonote[cellonoteinfo]
Out[1]:= {"do1f", "do1f", "so0f", "so0f", "la0f", "la0f", "mi0f", "mi0f", \
"fa0f", "fa0f", "do0f", "do0f", "fa0f", "fa0f", "so0f", "so0f"}
3.Third, replace the note name in sequence by sound, then we will get the sound in sequence. We use the association "notetosoundass"
cello = Sound[Flatten@Table[Replace[cellonote, notetosoundass, 1], 23], {0}];
vio1 = Sound[Replace[violinnote, notetosoundass, 1], {8}];
vio2 = Sound[Replace[violinnote, notetosoundass, 1], {16}];
vio3 = Sound[Replace[violinnote, notetosoundass, 1], {24}];
0,8,16,24 at the end of code means the insert time of different instruments.
4.Finally, combine it
![Completed Canon][9]
You can enjoy it [here][10]
BTW, this code runs 2 minutes to generate final music, i think it can be better, if you have another idea, glad to see your comment.
Both Matlab and Mathematica code are below.
[1]: https://www.youtube.com/watch?v=cVKsSd6Ji1E&t=4s
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Pachelbel%27s_Canon_-_Mus.MS_16481-8_Page_1.jpg&userId=1247466
[3]: https://www.bilibili.com/video/av10699321/?from=search&seid=84894214186229529
[4]: https://en.wikipedia.org/wiki/Note_value
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A72017-12-17%E4%B8%8B%E5%8D%886.08.48.png&userId=1247466
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A72017-12-17%E4%B8%8B%E5%8D%886.16.13.png&userId=1247466
[7]: https://en.wikipedia.org/wiki/Canon_%28music%29
[8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A72017-12-17%E4%B8%8B%E5%8D%886.54.08.png&userId=1247466
[9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A72017-12-17%E4%B8%8B%E5%8D%887.31.58.png&userId=1247466
[10]: https://www.youtube.com/watch?v=cVKsSd6Ji1E&t=4sQiuHao Chen2017-12-17T07:15:02Zchange speed setting for remote kernels?
http://community.wolfram.com/groups/-/m/t/1267044
If you add remote kernels via menu Edit -> Preferences -> Parallel -> Remote Kernels they are all given the default value of Speed=1 which assumes that all machines are identical, but if one of them is much slower than the others, then it will slow down the computation instead of speeding it up, because all nodes will be given the same amount of work to do. This value is shown by the "Parallel Kernel Status" dialog if one enables it via "Select Columns..."
So, my question is: is it possible to change the Speed setting so as to help Mathematica 11 decide the optimal amount of work to give to each node? If so, how?Tigran Aivazian2018-01-17T10:30:26ZConvert a Mathematica Notebook into a fully interactive web page?
http://community.wolfram.com/groups/-/m/t/1266033
I have a Mathematica notebook that contains some animations based on numerical solutions to differential equations, with a few input parameters (either directly typed in or using sliders). I can't find a tutorial (either online or within the Help system) on how to convert this into an online web file that my students can explore for themselves. Ideally, it should show all the same content as the nb, but also be able to actually run the animation, with students being able to change the input. I tried simpleminded commands like "Export", but although a bunch of html files were created, they don't seem to do anything in my browser (Safari). Any hints would be appreciated!Sebastian Kuhn2018-01-15T17:08:09ZImprove paclet formatting?
http://community.wolfram.com/groups/-/m/t/1266698
Cross posted on StackExchange: [Improving paclet formatting](https://mathematica.stackexchange.com/questions/163854/improving-paclet-formatting)
---
For such an increasingly relevant data type the `Paclet` has a particularly useless formatted form.
Can we do better?
In particular we'll want the `Paclet` [`Format`](http://reference.wolfram.com/language/ref/Format.html) to be attractive, show particularly relevant paclet info, and be customizable.
Here's my version, to get people started:
pacletKeyOrdering =
{
"Name", "Version", "Creator",
"Description", "Root", "WolframVersion",
"MathematicaVersion", "Internal", "Loading",
"Qualifier", "SystemID", "BuildNumber",
"Tags", "Icon", "Categories",
"Authors", "Extensions"
};
With[{keyOrdering = pacletKeyOrdering},
pacletInfoAssociation[PacletManager`Paclet[k__]] :=
KeySortBy[First@FirstPosition[keyOrdering, #] &]@
With[
{
base =
KeyMap[Replace[s_Symbol :> SymbolName[s]], <|k|>]
},
ReplacePart[base,
"Extensions" ->
AssociationThread[
First /@ Lookup[base, "Extensions", {}],
Association@*Rest /@ Lookup[base, "Extensions", {}]
]
]
]
];
If[! AssociationQ@$pacletIconCache, $pacletIconCache = <||>];
pacletGetIcon[a_Association] :=
Replace[
FileNames[
Lookup[
a,
"Icon",
"PacletIcon.m" | "PacletIcon.png"
],
a["Location"]
],
{
{f_, ___} :>
Lookup[$pacletIconCache, f, $pacletIconCache[f] = Import[f]],
{} :>
With[{f =
"https://github.com/b3m2a1/mathematica-BTools/raw/master/\
Resources/Icons/PacletIcon.png"
},
Image[
Lookup[$pacletIconCache, f, $pacletIconCache[f] = Import[f]],
ImageSize -> 28
]
]
}
];
$formatPaclets = True;
Format[p_PacletManager`Paclet /;
($formatPaclets && AssociationQ@
pacletInfoAssociation[p])] :=
With[{a = pacletInfoAssociation[p]},
RawBoxes@
BoxForm`ArrangeSummaryBox[
"Paclet",
p,
pacletGetIcon[a],
KeyValueMap[
BoxForm`MakeSummaryItem[
{Row[{#, ": "}], #2},
StandardForm
] &,
a[[{"Name", "Version"}]]
],
Join[
{
If[KeyMemberQ[a, "Location"],
BoxForm`MakeSummaryItem[
{Row[{"Location", ": "}],
With[{l = a["Location"]},
Button[
Hyperlink[l],
SystemOpen[l],
Appearance -> None,
BaseStyle -> "Hyperlink"
]
]},
StandardForm
],
Nothing
]
},
KeyValueMap[
BoxForm`MakeSummaryItem[
{Row[{#, ": "}], #2},
StandardForm
] &,
KeyDrop[a, {"Name", "Version", "Location"}]
]
],
StandardForm
]
];
FormatValues[PacletManager`Paclet] =
SortBy[
FormatValues[PacletManager`Paclet],
FreeQ[HoldPattern[$formatPaclets]]
];
This is what I use in my own packages. It makes paclets that look like this:
PacletFind /@ {"BTools", "ChemTools"} // Flatten
[![img][1]][1]
(*sorry about bad raster quality*)
Of course where this is actually useful is that it shows you what's inside the paclet:
PacletFind["MQTTLink"][[1]]
[![asdasd][2]][2]
[1]: https://i.stack.imgur.com/yeIuE.png
[2]: https://i.stack.imgur.com/WCeVf.pngb3m2a1 2018-01-17T05:10:59ZCalling WL users in Charleston, ATL, DC, Raleigh-Durham, Baltimore, Chicago
http://community.wolfram.com/groups/-/m/t/1266493
Hi all --
I'm looking to connect with some Wolfram language power-users located near the following areas:
- Charleston, SC
- Atlanta, GA
- Washington, DC
- Raleigh, NC
- Baltimore, MD
- Chicago, IL
I work with our Commercial team to establish and support licensing in these major cities, and I think it'd be really beneficial to work with some of our more passionate users there. Obviously, being located in Champaign, I have some limitations to my knowledge of as well as my access to these areas, so I think collaborating with you all to either get a better idea of the tech landscape or even working to raise awareness could be a worthwhile effort.
Curious in connecting to some of you. Any level of interest from "I can help you learn more about this city's tech landscape and its networking opportunites" to "here's some connections I have in the area" to "let ME be your Wolfram Language evangelist for my city" is appreciated. Feel free to comment on here or shoot me a quick email at samt@wolfram.com if you're interested. Excited to connect!Sam Tone2018-01-16T23:31:20Z[✓] Avoid problems with code execution of a button?
http://community.wolfram.com/groups/-/m/t/1266463
I want to execute the function moverIntXx within the button and nothing happen. If I execute the function outside the button, the function runs fine. What is that I don' t understand? Thanks.
SetAttributes[moverIntXx,HoldFirst];
moverIntXx[var_,n_]:=Module[{t},
t=Flatten[Table[{1,2,3},{i,1,n}]];
Map[(Pause[0.05];FinishDynamic[];var=#)&,t];
];
Dynamic[var]
Button[
Style[Tooltip["Clic"], Red,FontFamily->"Palatino",18],
moverIntXx[var,6],Appearance->"Frameless"]Ernesto Espinosa2018-01-16T17:22:48Z[✓] Plot and print out values of a function in NestList?
http://community.wolfram.com/groups/-/m/t/1264365
Hi,
I'm new to Mathematica and I'm having troubles in understanding how to evaluate a custom function that I applied NestList to. Here's my function:
f[x_, m_] := m*x /; 0 <= x < 1/2
f[x_, m_] := m*(1 - x) /; 1/2 <= x <= 1
x = 0.2
m = 2
Next I got NestList like this:
NestList[f, {0.2, 2}, 4]
which have given me following output:
{{0.2, 2}, f[{0.2, 2}], f[f[{0.2, 2}]], f[f[f[{0.2, 2}]]],
f[f[f[f[{0.2, 2}]]]]}
Now instead of printing f f f .... f f I'd like to see actual values of the function f after evaluation such as {value 1, value 2, value 3, ..., value n}. Moreover I'd like to plot such a NestList where values in NestList would be coordinates of n points on axis.
Any help, advice or example would be greatly appreciated.
EDIT: I'm studying Dynamic systems and trying to compute and plot so called ["tent map"] (https://en.wikipedia.org/wiki/Tent_map)Nikol Skorupova2018-01-12T10:03:28Z[✓] Change TimeConstraint option in Mathematica?
http://community.wolfram.com/groups/-/m/t/1266551
Hello ,
I would like to solve a Limit Question in Mathematica but when i click on Step by step solution then i get this error.
"WolframAlpha::timeout: The call to WolframAlpha[lim ((ln(1+sinx)\[Sqrt]sinx)/\[Sqrt](3x^3(1+x+2x^2-5x^3)) as x->0] has exceeded 20.` seconds. Increasing the value of the TimeConstraint option may improve the result."
Can anyone help me to change TimeConstraint?
Thank you in AdvanceSalahuddin Sediqi2018-01-16T11:14:48Z[✓] Handle discontinuities at the boundary in DSolve and NDSolve?
http://community.wolfram.com/groups/-/m/t/1266614
I feel like there's an easy answer to this. Laminar flow in a cylinder:
DSolveValue[mu/r D[r u'[r], r] == dp, u[r], r]
c1 log(r)+c2+(dp r^2)/4/mu
(*log[0] is -infinity, but apply boundary conditions sets c1=0:*)
DSolveValue[{mu/r D[r u'[r], r] == dp,u'[0]==0,u[1]==0}, u[r], r]
dp/4/mu (r^2-1)
In DSolve it evaluates fine but with the error "For some branches of the general solution, unable to compute the limit at the given points. Some of the solutions may be lost"
NDSolve fails with a 1/0 error. What's the best way of handling this? I have a more difficult problem I need to resolve where one of the dependent variable goes to zero at the boundary and is in the denominator (the numerator goes to zero faster).Eric Smith2018-01-16T15:40:54Z[✓] Use NDSolve to solve three dimensional (t,x,y,) pde?
http://community.wolfram.com/groups/-/m/t/1266574
Consider the following code:
Clear[x, t, xMin, xMax, TMax, yMin, yMax];
TMax = 3.73; xMin = -Sqrt[2] Pi; xMax = -xMin; yMin = -Sqrt[
2] Pi; yMax = -yMin;
eqn = D[h[t, x, y],
t] == -Div[Grad[h[t, x, y], {x, y}]/h[t, x, y], {x, y}] -
Div[Grad[Laplacian[h[t, x, y], {x, y}], {x, y}]*h[t, x, y]^3, {x,
y}];
bcs = {h[0, x, y] == 1 - 0.1 Cos[Sqrt[2]/2*Sqrt[x^2 + y^2]],
h[t, x, yMin] == h[t, x, yMax], h[t, xMin, y] == h[t, xMax, y]};
hsol = NDSolveValue[{eqn, bcs},
h[t, x, y], {t, 0, TMax}, {x, xMin, xMax}, {y, yMin, yMax}]
******************************************************
The above code can be run but show no results when I try to plot it using Plot3D,like: Plot3D[hsol[0, x, y], {x, xMin, xMax}, {y, yMin, yMax},
PlotRange -> All]. Does anyone can help me with this? Thanks a lot.Yixin Zhang2018-01-16T11:27:46Z[✓] Factor out matrices in expressions?
http://community.wolfram.com/groups/-/m/t/1265715
Hi Community,
I am working on a tutorial for matrix algebra, I cannot figure out how to make Mathematica identify and replace previously defined symbols in calculations. For example. I have defined
rules = {IdentityMatrix[2] -> Subscript[\[Sigma], 0],
PauliMatrix[1] -> Subscript[\[Sigma], 1],
PauliMatrix[2] -> Subscript[\[Sigma], 2],
PauliMatrix[3] -> Subscript[\[Sigma], 3]}
So when I make
Grid[Join[{Table[PauliMatrix[i] // MatrixForm, {i, 3}]},
Table[MatrixForm[PauliMatrix[i].PauliMatrix[j] /. rules], {i,
3}, {j, 3}]]]
I get `Subscript[\[Sigma], 0]` in the diagonal, but cannot figure out how I make Mathematica to identify the other elements as simply products of `+/- I` and the other Pauli matrices.
Or simpler put: how do I make Mathematica answer `I PauliMatrix[3]` to the input
PauliMatrix[1].PauliMatrix[2]
Kind regards
Mogens
Ps. Is it true that Solve etc. does not work on matrices, or is it just me? (I have tried to specify `Matrices[{2,2},Complexes]` as the domain but I get errors or nothing back)jallberg2018-01-14T20:51:08Z[CALL] Reddit DataViz Battle JAN2018: Visualize the Growth Rates of Algae
http://community.wolfram.com/groups/-/m/t/1257547
# Intro
One of the most popular Reddit's channels **Data Is Beautiful** (with multi-million membership of subscribers) has just started **Battle Competitions** for data visualizations that will run monthly. This is a call to Wolfram Community members to collaborate on **JAN 2018 Battle**.
***Direct reference to the JAN 2018 Battle***: https://redd.it/7nm6ed
## Solutions
- **Heatmap of inter- and intra- species comparison** *by Vitaliy Kaurov*:
- http://community.wolfram.com/groups/-/m/t/1257577
- **Bubble chart for 4D data** *by Sander Huisman*:
- http://community.wolfram.com/groups/-/m/t/1257885
- **Population - pyramid like visualization**: *by George Varnavides*
- http://community.wolfram.com/groups/-/m/t/1258056
- **Growth Rate in "Intensity Space"** *by Henrik Schachner*
- http://community.wolfram.com/groups/-/m/t/1258281
- **Intraspecies comparison using RadarChart** *by Diego Zviovich*
- http://community.wolfram.com/groups/-/m/t/1260507
- **Interspecies comparison using HeatmapPlot** by *Anton Antonov*
- http://community.wolfram.com/groups/-/m/t/1261444
- **Scatter plot slices of temperature dynamics** *by Vitaliy Kaurov*
- http://community.wolfram.com/groups/-/m/t/1261948
- **RadarChart for each pecies** by *Anton Antonov*
- http://community.wolfram.com/groups/-/m/t/1261438
## Rules of this thread
Reddi requires direct links to the images. Hence a separate post is necessary. Here are the steps:
- Make a separate post solving the challenge with detailed title describing your specific method of visualization and starting with tag [Reddit-DiBB0118] (Data is Beautiful Battle 01/2018)
- Make a comment in this thread simply stating the title and copying your post URL.
See my example in the comments. I will collect the solutions in the "solutions" section above. This method enables you to post your own posts on Reddit if you want to keeping your authorship.
## Goal
I simply suggest that Wolfram Community members brainstorm in the comments below about how the best to visualize the dataset. Feel free to submit **your own** solutions to Reddit if you want to as they require the original authors. The main goal though is simply to have fun here on Community. **Don't forget to vote up the posts you like**.
## Important
Battles have simple rules explained clearly in the Reddit battle thread linked above. To not get disqualified it is advised to read rules carefully. You can ask Reddit admins any additional questions directly in the thread comments. I recommend reading other people comments as they clarify the nature of the dataset.
## Getting the data w/ Wolfram Language (WL)
The dataset is located at a web page: http://aquatext.com/tables/algaegrwth.htm
The nature of the data is clear from the website description. It is easy to get the raw data with the following WL command:
raw = Import["http://aquatext.com/tables/algaegrwth.htm", "Data"] /."0..06" -> .06;
You need `/."0..06" -> .06` because the data has a clerical error resulting in the import of a string instead of a number. One way of obtaining a simple rectangular array / table of data is:
data=Cases[raw,{_String,__?NumberQ},Infinity]/.
x_List/;First[x]=="Temperature":>{"Temperature",5,5,10,10,25,25,30,30};
which can be viewed as
TableForm[data]
![enter image description here][3]
[1]: https://www.reddit.com/r/dataisbeautiful/
[2]: http://community.wolfram.com/groups/-/m/t/1257577
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-01-02at6.20.30PM.png&userId=11733Vitaliy Kaurov2018-01-03T00:33:35ZUsing Basic JSON REST Services in Mathematica
http://community.wolfram.com/groups/-/m/t/1262929
I recently had a job interview where I was given the following problem and I decided to tackle it with Mathematica vs. Groovy; it seemed very simple to accomplish using Mathematica: *(Hopefully they take kindly to it)*
- There’s a “fake” REST service available for testing at:
http://jsonplaceholder.typicode.com/
- Write some code in the Groovy programming language that uses the
“posts” API published at http://jsonplaceholder.typicode.com/posts,
which reports back some fake blog posts including a userid, post id,
title, and body.
- Retrieve the records from the API and generate a report that lists only the users who wrote posts where the post title starts with the
letter “s” along with the number of such posts for each of those
users.
- Use the user's name in the report, not the numerical user ID.
- Return to us the report that's generated, along with the (working)
code that generated it.
First, let's import our posts from the website as RawJSON format and generate a Dataset from it which is much more convenient to work with:
posts = Import["http://jsonplaceholder.typicode.com/posts", "RawJSON"];
postsDataSet = Dataset[posts]
![enter image description here][1]
Next, let us filter out all of the posts whose bodies of text start with the string character "s":
filterPostsDataSet = postsDataSet[Select[StringTake[#title, 1] == "s" &]]
![enter image description here][2]
We are left with 9 entries and all we need to do is keep the userId values associated with these:
userIDs = filterPostsDataSet[All, "userId"]
![enter image description here][3]
Now we need to retrieve the user's information attached to these Id values; although not specifically stated I assumed these could be found at http://jsonplaceholder.typicode.com/users. Thus, we simply import these values and, like before, wrap them in a Dataset.
users = Import["http://jsonplaceholder.typicode.com/users", "RawJSON"];
usersDataSet = Dataset[users]
![enter image description here][4]
Although I feel there is a more elegant way - I am going to make a list of just the users names from this Dataset to work with using the following:
userResults =
Table[usersDataSet[Select[#id == userIDs[[i]] &]][[1]]["name"], {i, 1, Length[userIDs]}]
Additionally, I want to keep a list of the *unique* user names since some might be duplicated in the previous list:
uniqueUsers = DeleteDuplicates[userResults]
Finally, I will create a final list which is essentially my required report, which will be a list of pairs. Each pair will contain the unique user name as well as the count of how many times that unique user name appeared in the original list. I put this in TableForm just for aesthetic value. This can then be exported to the desired format later on if necessary.
uniqueUserPosts = Table[{uniqueUsers[[i]], Count[userResults, uniqueUsers[[i]]]}, {i, 1, Length[uniqueUsers]}] // TableForm
![enter image description here][5]
In conclusion, I think that in the future using Mathematica in working with REST API's could and should be allowed if not encouraged as a proper scripting languages in many commercial and industrial settings. So - what do you guys think?? Is this better or worse than what could be done in Groovy or other scripting languages? Also, I feel that I could condense and optimize my code in areas and would love to hear feedback on that.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Result1.png&userId=856782
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=7292Result2.png&userId=856782
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=1220Result3.png&userId=856782
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Result4.png&userId=856782
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=5573Result5.png&userId=856782William Duhe2018-01-10T05:24:46ZSolve a non-linear system of equations?
http://community.wolfram.com/groups/-/m/t/1265768
I have a set of non-linear equations that I want to solve numerically. The "Solver" of Excel is sometimes able to solve it, but often fails (ends up with not-a-number values and gives up).
I am thinking of switching to Mathematica or Matlab. Would appreciate if someone gave me any guidance about the pros and cons of these two.Jay Cal2018-01-15T09:34:20ZSolved: Linux Interface Toolbar and Font Size
http://community.wolfram.com/groups/-/m/t/1266184
Thought I'd post something I was struggling with in order to get Mathematica (and any sub-menus it might launch) to display correctly on high resolution monitors in Linux.
The default ScreenResolution is 72dpi in a newly installed Mathematica. My monitor (and almost all modern monitors) use a higher resolution. In my case 96dpi. This means that everything rendered is tiny (it renders to 72/96 of what it was intended to run at). Controlling some fonts fails to control sizes in menus, icons, and tool bars in general. Bits and pieces of Mathematica can be enlarged through font or ScreenResolution changes, but it is difficult at best to get even part of what is too small back to a normal size. So here is how to fix this with a single step...
Setting environment variables like this will fix the issue...note that 96/72, the dpi of actual monitor versus what seems to sometimes be hard coded into Mathematica, is about 1.33. This will correct the issue if starting on command line:
QT_AUTO_SCREEN_SCALE_FACTOR=1 QT_SCALE_FACTOR=1.33 Mathematica &
Starting Mathematica like this will allow the palettes, icons, buttons, and window frames to enlarge uniformly.Dan Stimits2018-01-16T02:04:25Z[✓] Calculate confidence interval for an expected value in linear model?
http://community.wolfram.com/groups/-/m/t/1265869
Hi everyone
I'm sure there is a really simple solution for my problem but I just can't figure it out.
After using LinearModelFit to estimate a mode (lm)l, I calculated an expected point estimate using some fixed values (lm[1,2,3]). I'd now like to calculate a confidence interval for my point estimate. What would be the way to do it?
ThanksLuka Vucicevic2018-01-15T19:41:21Z[✓] Use of Gradient in FindMinimum?
http://community.wolfram.com/groups/-/m/t/1261346
I use FindMinimum using objective and gradient functions that take a matrix and vector as inputs, as in
FindMinimum[f[mat, vec], {{mat, matstart}, {vec, vecstart}}, Gradient :> g[mat, vec}], Method -> "QuasiNewton"]
The arguments to f[mat,vec] and g[mat,vec] are a matrix (mat) and a vector (vec). FindMinimum wants the Gradient function g to return a vector, which makes sense. Question is in which order should the derivatives be specified? The most logical option appears to be that corresponding to Flatten[{mat,vec}]... but I'm not having much luck with that.
Thanks for any help.
-EricEric Michielssen2018-01-07T16:29:02Z