Author: pdneumiller

If you are using Linux or Apple your mileage may very with this post. If you want to figure it out for Apple or Linux it would be cool if you posted your method as a comment to this blog!

I am going to cover creating a Windows 10 keyboard macro for Mathematica in Windows 10, and show how it can save you time with Wolfram built in functions. I am going to use some Set theory functions as an example of how this can save you some carpal tunnel impact, Namely Union[],Intersection[], and Complement[].

In Windows 10 you should have the Windows Mouse and Keyboard app which you can download here if you don't have it. Open the app and it will show your devices. Mine opens to my Microsoft mouse so I scroll over to they Keyboard I want to create hot keys for and it looks like this.

Phil's Keyboard

First we will add a Macro that types the keys needed to get the Wolfram wolf icon. Which are [Esc Key]wolf[Esc Key].

Click app-specific settings and scroll to Mathematica (don't pick the Kernel!) and pick that as your App. My screen looks like this now:

Now we are ready to add a macro. Scroll to New and click it. Now create a new Macro. I named mine "Wolfy" of course. Then use the special keys menu in the Macro editor to select the escape key. Then type wolf in lower case and add the escape key again. Your screen should look something like this.

We are not done, we need to assign our macro to a key or a key combination like Alt-w for example. Just hit the back arrow the macro is save automagically and keep going back to the base menu. Scroll till you see Assign a macro (Wolfy). My screen looks like this.

Click the CBS eye looking icon to the top right of the Keyboard image to toggle the keys available for programming. I picked the task view key. Now scroll to the macro and pick Wolfy or whatever you called yours. If you dig around a bit in the tool you can find out how to assign Macros to key combination like Windows-W but I'm lazy and that would make this post even longer!

Go into Mathematica and press you hot key or hot key-combination if you figured that out and you will see Wolfy magically appear.

OK. Why is this useful?

Hopefully I can motivate with you with what motivated me. I have been doing a bunch of set theory stuff lately. I found the Wolfram builtin functions useful, but I wanted to add some additional logic and protection to my functions. I also wanted hot keys for these functions with the benefit of icon in the function name, i.e. Wolfram's wolf. Let's say I want to use the built in functions set Union, Intersection, and Complement. We can use the Wolfy icon in our new function names which makes them short fast and look cute. Here are the function definitions with some exception handling added to each function.

Lets test our new Keyboard Macro Wolfy functions.

If you found this post useful you can download the Wolfram Notebook from here. If you have any ideas on how to improve this post, or learn how to add "Wolfy" functions to Linux or Mac leave a response to this post. By the way the "Spikey" icon is just to the left of the Wolfy icon so adding Spikey functions would work the same way.

We examine the electrostatic vector field functions in this post. This is roughly patterned after chapter 1 of Shey's classic book Div, Grad, Curl and All that...

2D Position Vector

Now a tangential vector field:

Tangential 2D vector field

Now let's look at the charge between two particles in free space in MKS units. This law of Physics was discovered by the French physicist Charles-Augustin de Coulomb (June 1736 - 23 August 1806). He was best known for developing Coulomb's law, the definition of the electrostatic force of attraction and repulsion, but also did important work on friction. The SI unit of electric charge, the coulomb, was named after him.

We present here a simple program to generate a variety of random graphs with a variable number of vertices and edges and Random edge weights, either directed or undirected. You can put an insane number of vertices in and it will run ... but it will take a while...

Compute Shortest Path Max / Min Flow on Random Graph

If you want the Random graph to be directed you can change the DirectedEdges-> parameter in the RandomGraph[] function. Also if you want a different number of vertices or edge density you ad adjust the numVertices, numEdges parameters as it suites you. Here is an example output. Edge weights are distributed uniform randomly over [0, 1].

Shortest Path through Random GraphMaximum FlowMin Flow Cost

Here is a shortest path plot with 1500 nodes. It works but it gets difficult to visualize at this scale... You can sort of see the red vertices in there right? 🙂

You have to calibrate your Axes and the pick the trace color of the plot which it offers in a menu of dominant colors derived from the chart. It's pretty cool that the points I got back had a correlation of nearly 1 for the original data in Mathematica.

The tool also has an option WebCam option and can import and export JSON which is nice as well. Overall I give this an overall rating of 9.5/10! I still haven't found my holy grail screen scraper yet but this one works well for manual scraping of charts.

For builders out there everywhere that love the Raspberry Pi, I recently thought of an interesting application of Mathematica on the Pi.

How about a game camera that recognizes the animal's you want to capture in memory on your game/animal(for you vegans) cam? Let's say you just want to see Deer and not hunters, hikers or all those blasted raccoons.

It turns out to be pretty simple with Mathematica, provided your Pi has access to the Internet and Wolfram's curated data.

Here is an image of a mature white tale buck.

Here is the one line Mathematica code to "recognize" the critter and the one line of code to display the results as a word cloud.

Since the tail of the deer could not clearly be seen in the photo the most prominent feature of the image is "its a deer!".

Let's try a picture where the tail can be seen on the Deer.

Here are the results:

Pretty cool huh? Now let's try and trick it.

Well it has raccoon as one of the critters but didn't list deer.

There will be false positives... But you can use machine learning on your captured images to train the system to be better all the time!

You can try this yourself right here at Wolfram's image identify project here.

Thanks for reading, and enjoy Mathematica!

Phil

Disclaimer:

Make sure to check the Wolfram licensing -- this is strictly for non-commercial use.

Recently I downloaded PIPE2 which is the Platform Independent Petri Net editor written in Java. It's an impressive open source and FREE tool to that allows you to model Generalized Stochastic Petri Nets (GSPNs).

So I fired it up and decided to build a simple Producer / Consumer model, aka the "bounded buffer problem". Here's the GSPN I drew with the PIPE2 editor.

Notice that the highest firing rate for the producer is 100 times that of the consumer (on both timed transitions). This means we would mostly expect the input buffers to be highly utilized and the PIPE2 analysis shows this.