wolfram-mathematica

Remap Caps lock key to Esc in Mma 7

倾然丶 夕夏残阳落幕 提交于 2020-01-01 02:10:56
问题 TLDR : How do I get CapsLock to translate to "ShortNameDelimiter" in Mma 7? I like pretty text in my mma notebooks, and often define functions as f[\[Alpha]_] =... so as to match the exact equation that I'm working with. As such, it involves a lot of Esc - letter - Esc sequences, and reaching for Esc every other stroke breaks my flow of typing. Now, the CapsLock key is seldom used (I can't remember the last time I needed it), but conveniently placed (your pinky is right there!). Remapping it

What would a minimal example for a choropleth map in Mathematica look like?

旧巷老猫 提交于 2019-12-31 22:41:33
问题 What would a minimal example for a choropleth map in Mathematica look like? I can read in a ESRI Shapefile using Import , but do not know how to work with the imported result. 回答1: Graphics[ { ColorData["ThermometerColors"][ Rescale[CountryData[#, "GDPPerCapita"], {100, 50000}] ] /. HoldPattern[Blend[___]] -> Yellow, CountryData[#, "Polygon"] } & /@ CountryData[] ] And why the replacement? If there are no data of the required type for a given country CountryData returns Missing["NotAvailable"

What would a minimal example for a choropleth map in Mathematica look like?

非 Y 不嫁゛ 提交于 2019-12-31 22:41:28
问题 What would a minimal example for a choropleth map in Mathematica look like? I can read in a ESRI Shapefile using Import , but do not know how to work with the imported result. 回答1: Graphics[ { ColorData["ThermometerColors"][ Rescale[CountryData[#, "GDPPerCapita"], {100, 50000}] ] /. HoldPattern[Blend[___]] -> Yellow, CountryData[#, "Polygon"] } & /@ CountryData[] ] And why the replacement? If there are no data of the required type for a given country CountryData returns Missing["NotAvailable"

Sprintf equivalent in Mathematica?

冷暖自知 提交于 2019-12-31 17:52:52
问题 I don't know why Wikipedia lists Mathematica as a programming language with printf. I just couldn't find the equivalent in Mathematica. My specific task is to process a list of data files with padded numbers, which I used to do it in bash with fn=$(printf "filename_%05d" $n) The closest function I found in Mathematica is PaddedForm . And after some trial and error, I got it with "filename_" <> PaddedForm[ Round@#, 4, NumberPadding -> {"0", ""} ]& It is very odd that I have to use the number 4

Stable Sorting, ie, Minimally-Disruptive Sorting

岁酱吖の 提交于 2019-12-31 14:43:30
问题 Suppose I have a list of things (numbers, to keep things simple here) and I have a function I want to use to sort them by, using SortBy. For example, the following sorts a list of numbers by last digit: SortBy[{301, 201}, Mod[#,10]&] And notice how two of (ie, all of) those numbers have the same last digit. So it doesn't matter which order we return them in. In this case Mathematica returns them in the opposite order. How can I ensure that all ties are broken in favor of how the items were

Is there a way to clear everything before starting in Mathematica?

故事扮演 提交于 2019-12-31 12:52:18
问题 In MATLAB there is the function clear to delete all current variables. This is very useful if you start something totally new and don't want to get conflicts with earlier calculations. I'm searching something similar for Mathematica now, but I couldn't find anything except of Clear[VAR] which removes only the variable VAR . 回答1: I recommend one of two methods: 1. Keyboard shortcut to Quit[] the kernel There is a system file KeyEventTranslations.tr that you can edit to customize keyboard

Random rational numbers generation

我的梦境 提交于 2019-12-31 12:49:00
问题 Rationals are enumerable. For example this code finds k-th rational in open interval 0..1, with ordering that {n1, d1} is before {n2, d2} if (d1<d2 || (d1==d2 && n1<n2)) assuming {n,d} is coprime. RankedRational[i_Integer?Positive] := Module[{sum = 0, eph = 1, den = 1}, While[sum < i, sum += (eph = EulerPhi[++den])]; Select[Range[den - 1], CoprimeQ[#, den] &][[i - (sum - eph)]]/den ] In[118]:= Table[RankedRational[i], {i, 1, 11}] Out[118]= {1/2, 1/3, 2/3, 1/4, 3/4, 1/5, 2/5, 3/5, 4/5, 1/6, 5

Syntax Coloring In Mathematica

浪子不回头ぞ 提交于 2019-12-31 10:42:19
问题 How could user-defined function symbol such as f in f [x_] = 2 x or variable symbols such as lotto in lotto = Table[2, {10}]; be colored automatically ? In Syntax coloring on M8 no option is offered for this. Only Local Variables or Global symbols that have no values assigned. 回答1: This is not exactly what you asked for, but it may be useful to you. You can highlight symbols by context, using this method: SetOptions[$FrontEndSession, AutoStyleOptions -> {"SymbolContextStyles" -> {"highlight`"

Doing probabilistic calculations on a higher abstraction level

谁都会走 提交于 2019-12-31 08:32:25
问题 To the downvoters: this isn't a question about mathematics, it's a question about the programming language Mathematica . One of the prime characteristics of Mathematica is that it can deal with many things symbolically. But if you come to think about it, many of the symbolic features are actually only halfway symbolic. Take vectors for instance. We can have a symbolic vector like {x,y,z}, do a matrix multiplication with a matrix full of symbols and end up with a symbolic result and so we

Doing probabilistic calculations on a higher abstraction level

扶醉桌前 提交于 2019-12-31 08:31:47
问题 To the downvoters: this isn't a question about mathematics, it's a question about the programming language Mathematica . One of the prime characteristics of Mathematica is that it can deal with many things symbolically. But if you come to think about it, many of the symbolic features are actually only halfway symbolic. Take vectors for instance. We can have a symbolic vector like {x,y,z}, do a matrix multiplication with a matrix full of symbols and end up with a symbolic result and so we