Skip to main content

Posts

front end - How to find out available fonts from within Mathematica?

How to find out available fonts on the system from within Mathematica? When I do Style["foobar", FontFamily -> "Foobar"] how do I know which font the displayed output is using/falling back to use? Answer The relevant line from this SO post : fontlist = FE`Evaluate[FEPrivate`GetPopupList["MenuListFonts"]]; Update: The content of the "MenuListFonts" list is system-dependent. In Windows Vista, I get a list that contains only FontFamily : Panel@Row[fontlist[[;; 60]] /. Rule[x_, y_] :> Style[ToString@x, 14, FontFamily -> y], " \[FilledSquare] "] On a Mac system, it appears that the list contains tuples of FontFamily, FontWeight and FontSlant . That is, fontlist /. Rule[x_, y_] :> Style[x, 20, FontFamily -> y] gives

probability or statistics - Winsorizing in Mathematica and the R package DescTools yields differing results

I am currently trying to winsorize several datasets up to 1000 datapoints in R and in Mathematica for using those in regression estimations afterwards. Following the suggestion in the question http://mathematica.stackexchange.com/questions/152936/list-with-inadequate-structure-in-the-output-of-a-defined-function , I used Clip[grate16, Quantile[grate16, {.05, .95}]] to winsorize my data in Mathematica . Yet, if I use the Winsorize function from the package 'DescTools' in R with the code Winsorize(grate16, probs = c(0.05, 0.95)) for exactly the same datasets, the results differ for some observations from about the 3 decimal-digit level which leads to heavily differing end results. Cursory documentation for this function can be found here . The code (in GitHub) for this function can be found here . Since the deviations are so large for the same datasets, I do not think this is a numerical accuracy issue. I tried differing levels of precision and accuracy in Mathematica which, ...

evaluation - Understanding Villegas-Gayley

Temporary message: I have written another question about the behaviour the code by Oleksandr R. . Sadly I clicked "discard" and that was lost. I am a bit demotivated now and in order to not let the work pile up I chosen the least juicy part of the question to be the new shortened version. Retract your upvote if you will. In this nice answer , Mr.Wizard writes mk : MakeBoxes[(Hold | HoldForm | HoldComplete | HoldPattern)[__], _] := Block[{$hldGfx = True, Graphics, Graphics3D}, mk] /; ! TrueQ[$hldGfx] which is an application of the Villegas-Gayley pattern Question: How does the Villegas-Gayley pattern work? Answer Say there's a function with only DownValues (as an example). The objective is to inject some wrapper code to it. You want to replace the function definition with your own code, but allowing your own code to call the unmodified function. For example, you might want to add preprocessing or postprocessing. All this, without requiring to modify existing definitio...

formatting - User-defined usage message template; removing repeated text

In Mathematica 9.0.1 , I want to write a user-defined template for a function that I wrote: myfunc Remove[myfunc] myfunc::usage = "myfunc[x,y,z] is a function. myfunc[x,y,z,w] is another function." with the result: As you can see, within the description myfunc is (in my opinion) unnecessarily repeated. In fact, templates for built-in functions do not behave that way. For example, look at the template for the Integrate function: The function name Integrate is not repeated in the description. How do I tell Mathematica not to repeat the name of the function inside the description? Answer The built-in function templates displayed by the Input Assistant when Shift + Ctrl + K -ing the symbol name are NOT drawn from either the package file that holds the symbol. Check and edit e.g. Calendar`DaysPlus in $InstallationDirectory\AddOns\Packages\Calendar\Calendar.m . It has one simple usage though the Input Assistant shows two. the usage file: $InstallationDirecto...

About Slicing through Graphics3D

Recently I have seen a code in mathematica about Slicing through Graphics3D in Slice through Graphics3D . My questions is: Is it possible to fill out these spheres? I have problem with generating randomly distributed filled spheres inside cube. Bakha

functions - Wrong behaviour of ComplexExpand and Conjugate

This input gives the wrong result ComplexExpand[Conjugate[f[x]], {x}] (*f[x]*) instead of Conjugate[f[x]] . In particular it works well with some functions, e.g. ComplexExpand[Conjugate[f[x] /. f -> Sin], {x}] (*Cosh[Im[x]] Sin[Re[x]] - I Cos[Re[x]] Sinh[Im[x]]*) ComplexExpand[Conjugate[f[x, y] /. f -> Times], {x, y}] (*-Im[x] Im[y] + Re[x] Re[y] - I (Im[y] Re[x] + Im[x] Re[y])*) (note that ComplexExpand[Conjugate[f[x]], {x}]/. f -> Sin doesn't work) but not with others e.g. ComplexExpand[Conjugate[Dot[x, y]], {x, y}] (*x.y*) Any idea how to deal with this problem? How can I get the correct output for the last example f=Dot ? and for a generic function f ? Why the functions Dot and Times behaves in a different way?

function construction - Number by permutation

I want a function that compute number of permutation in lexicographical order. E.g. NumberByPermutation[{3,2,1}] = 6 NumberByPermutation[{1,2,4,3}] = 2 NumberByPermutation[{1}] = 1 maybe something like that already realesed in Mathematica? Answer Just a note - any method generating the permutations and the searching will get very slow very quickly, and blow RAM soon after. Something like this s/b much more efficient (e.g., on my goof-top, for permutations of length 10, it's ~30,000X faster : pr[{}] = 1; pr[{x_, y___}] := Tr[Clip[{y}, {x, x - 1}, {1, 0}] ] Length@{y}! + pr[{y}];