Mark Fisher's Mathematica packages and notebooks


Note (August 2026): Every package below was retested under Mathematica 15.0.1, and each entry now carries a status line. Several of the Version 5 packages fail only because they depend on Utilities`FilterOptions`, a standard add-on package removed in the Version 6 reorganization (2007). The small compatibility file FilterOptions.m recreates it using the modern FilterRules. Install it as Utilities/FilterOptions.m in a directory on $Path — for instance FileNameJoin[{$UserBaseDirectory, "Applications"}] — and the entries so marked below load and run unmodified.

Version 7 Packages


StereoImagery

The package contains two main functions, MakeStereo and MakeAnaglyph. MakeStereo takes a Graphics3D object and returns a GraphicsRow that contains a pair of Graphics3D objects viewed from slightly different angles. Positive values of the option AngularSeparation correspond to parrallel viewing (as opposed to cross-eyed viewing). MakeAnaglyph takes a pair of Graphics3D objects (such as the output of ShowStereo), converts them to bitmaps (using Image), removes (1) the green and blue from the left image and (2) the red from the right image, and combines the two images into one.

MakeStereo was modified from ShowStero by Larry Calmer. His version was designed to work with external graphics device. I modified (and simplified and updated) the code to produce a GraphicsRow in a notebook.

Status (August 2026, v15): working — MakeAnaglyph repaired August 2026 for the modern Image data layout; MakeStereo was never broken.


Version 6 Packages


PagePrint

This provides a simple way to print a graphic on a single page without header or footer. I use it all the time at work to produce handouts for presentations.

Status (August 2026, v15): loads cleanly; the printing path itself has not been retested.

RandomWalkMetropolis

This package implements the random-walk Metropolis version of the Markov Chain Monte Carlo (MCMC) algorithm. MCMC algorithms are used to draw from probability distributions. To use this package, put the file RandomWalkMetropolis.m in the directory ToFileName[{$UserAddOnsDirectory, "Applications", "RandomWalkMetropolis"}]. Load the package with Get["RandomWalkMetropolis`"] or Needs["RandomWalkMetropolis`"].

Status (August 2026, v15): verified working — and still useful, since Mathematica has yet to ship a general-purpose MCMC sampler.


Version 5 Packages


Plotting and Printing

PagePrint

This provides a simple way to print a graphic on a single page without header or footer.

Status (August 2026): superseded by the Version 6 PagePrint above.

DotPlot

The package DotPlot.m defines the function DotPlot, an enhnaced version of ListPlot combining points with "connecting" lines that leave a gap near the points. DotPlot effectively replicates the kind of plot used in Edward R. Tufte's The Visual Display of Quantitative Information (1983, Graphics Press: Cheshire, Connecticut) on pages 74–75 and elsewhere. This version (April 2006) also includes CirclePlot, which shows the data points as circles.

Status (August 2026): no longer runs — it leans on graphics internals (FullOptions among them) that were removed in Version 6, and would need a rewrite with modern options.

SpinGraphics

This package defines the function SpinGraphics, which has the same functionality as SpinShow (from Graphics`Animation`), except that SpinGraphics returns the list of Graphics objects it produces, facilitating the construction of animated GIFs, for example.

Status (August 2026): no longer runs (Graphics`Animation` was removed in Version 6); superseded by the native rotation and animation of Graphics3D.

StereoImagery

The package contains two main functions, MakeStereo and MakeAnaglyph. MakeStereo takes a Graphics3D object (or SurfaceGraphics object) and returns a pair of Graphics3D objects viewed from slightly different angles in a GraphicsArray. Positive values of the option AngularSeparation correspond to parrallel viewing (as opposed to cross-eyed viewing). MakeAnaglyph takes a pair of Graphics3D objects (such as the output of ShowStereo) or a pair of Graphics objects, converts them to bitmaps (using Rasterize, which uses the portable bitmap format), removes (1) the green and blue from the left image and (2) the red from the right image, and combines the two images into one.

MakeStereo was modified from ShowStero by Larry Calmer. His version was designed to work with external graphics device. I modified (and simplified and updated) the code to produce a GraphicsArray in a notebook.

Status (August 2026): no longer runs — among other things it defines its own Rasterize, which collides with the built-in of that name introduced in Version 6. Superseded by the Version 7 entry above.

ShowLive

This package provides a function (ShowLive) that passes 3-dimensional Graphics objects and animations to a "live" window using LiveGrahics3D.

ShowLive.m is adapted from code found at Omega Consulting. It uses LiveGraphics3D.

Status (August 2026): historical — LiveGraphics3D was a Java applet, and browsers no longer run applets.


Utilities

Difference

The file Difference.m contains the code for Difference for differencing vectors (and higher order tensors). Difference is implemented using polynomials in the lag operator to compute the kernel for ListConvolve. Note: There is a Difference function in the Times Series package available from Wolfram. Loading both packages creates a name "shadowing" problem.

Status (August 2026, v15): still works, but the built-in Differences (since Version 7) covers it.

DateFunctions

This package provides a number of functions to convert dates between list, string, and integer representations. The options have the same form as ConversionOptions for Import for CSV files. Also included are functions to convert between dates and index numbers suitable for alignment and plotting.

Status (August 2026): partly working — the plain conversions run, but the index functions depend on the removed Miscellaneous`Calendar`. Superseded in any case by the DateObject framework (since Version 10).


Stochastic Calculus

ItosLemma

This package implements Itô's lemma for any number of Itô processes with any number of arbitrarily-correlated Brownian motions. The notebook ItosLemma.nb contains usage examples.

Status (August 2026, v15): verified working — the examples notebook runs end to end, Black–Scholes finale included. (Assign TimeSymbol and friends first, as the notebook's opening section shows.)

EulerSimulate

EulerSimulate.m provides tools to simulate Itô processes with using the Euler approximation. Some usage examples are included. (Previous versions of this package required my package StandardNormal. This version of the package takes advantage of the speed improvements to RandomArray in Version 4 of Mathematica.)

Status (August 2026): no longer runs; superseded by the built-in ItoProcess and RandomFunction (since Version 9).


Statistics-Related

MaxEntSimplexDistribution

This package provides functions for working with the Maximum Entropy distribution on a simplex. It is a useful alternative to the Dirichlet distribution (for example). A companion paper is available.

Status (August 2026, v15): verified working — PDF and Gibbs sampler both run.

JRandomArray

JRandomArray uses JLink to implement a variety of pseudorandom number generators from the colt.jar Java library. The library includes a number of "random engines" (including the Mersenne Twister) that drive a number of probability distributions.

Unfortunately, most of the random number distributions do not produce arrays. However, the tiny class JRandomArray.class computes arrays of random numbers directly in Java, making the overall speed competitive with Mathematica itself. (If you are interested, see the code in JRandomArray.java.)

You will need to modify the line (in JRandomArray.m)
AddToClassPath["d:/data/packages/java"]
to reflect the directory where you place colt.jar and JRandomArray.class.

Note that if you want to produce an array of 107 random deviates, you will probably need to install JLink with the CommandLine option in order to increase the maximum amount of memory Java is allowed. (See the notes in JRandomArray.m and JRandomArray.nb.)

Status (August 2026): historical — RandomVariate long since made this unnecessary, and the hardwired class path betrays its Windows origins.

Additional information on the colt library (including documentation) can be found here.

ParticleFilter

This package implements a sampling-importance-resampling particle filter and backward simulation particle smoother.

Status (August 2026, v15): verified working — and still useful, since Mathematica has no built-in particle filter or smoother.

MetropolisMCMC

This package implements the Metropolis version of the Markov Chain Monte Carlo (MCMC) algorithm. MCMC algorithms are used to draw from probability distributions.

Status (August 2026): superseded by the Version 6 RandomWalkMetropolis above, which is a rewrite of this package.

GMM

The package GMM.m implements the Generalized Method of Moments estimator. This package requires the package EmpiricalLikelihood.m.

Status (August 2026, v15): verified working with the FilterOptions.m compatibility file (see the note at the top). Mathematica still has no built-in GMM.

EmpiricalLikelihood

The package EmpiricalLikelihood.m implements Art Owen's empirical likelihood estimator. This package requires the package MetropolisMCMC.m.

Status (August 2026, v15): verified working with the FilterOptions.m compatibility file (see the note at the top).


Term Structure

YieldCurve

The file YieldCurve.zip contains the Mathematica code files and the sample data files. The included version of BSplineBasis incorporates the bugfix. For further information read the included ReadMe.txt.

Status (August 2026): historical — written for Mathematica 2.2, it no longer loads (among other things it now collides with the built-ins BSplineFunction and Duration). Kept as a companion to the Varian volume.

Bug fix for YieldCurve/BSplineBasis

The file BSplineBasisFix.m contains a bugfix for the package BSplineBasis.m, which is included with the YieldCurve splining package that accompanied Computational economics and finance: Modeling and analysis with Mathematica, (1996, Springer-Verlag) edited by Hal Varian. The file fixes a problem that arose in Version 3 when the internal structure of InterpolatingFunction was changed. The problem occurs when the option FunctionalForm -> DLogDelta is set for the function DiscountFunction. The bug fix covers Versions 3 and 4 of Mathematica. A comment at the beginning of BSplineBasisFix.m explains how to use the fix.

Status (August 2026): historical — it patches Version 3/4 internals that have long since changed again.

User's Guide for YieldCurve

This is a user's guide for the package YieldCurve. The guide was written when the typsetting capabilities of Mathematica were not as well developed as now. Consequently, mathematical expressions within the text is written in TeX (between dollar signs).

AnnuitySolve

The package AnnuitySolve.m is designed to compute the series solution to a quasi-linear 2nd-order PDE. This PDE is central to general equilibrium models where the representative agent has recursive preferences. In such models, equilibrium consumption can be viewed as a dividend to be capitalized. By a change of numeraire, the problem can be transformed into an annuity problem. The notebook AnnuitySolve Examples.nb provides some examples. The notebook is, however, a work in progress.

Status (August 2026, v15): verified working with the FilterOptions.m compatibility file (see the note at the top) — the examples notebook then runs in full, numerical solver included.


Other

GaussianQuadrature

This package provides two functions: GaussianQuadraturePairs and GaussianProductRule.

GaussianQuadraturePairs produces a list of n abscissa/weight pairs {x,w} for n-point Gaussian quadrature. Four types of orthogonal polynomials are supported: HermiteH, LaguerreL, LegendreP, and ChebyshevT. (The Standard Package NumericalMath`GaussianQuadrature` computes abscissa/weight pairs only for the LegendreP case.) WorkingPrecision can be specified (including Infinity). The option ScalingParameters can be used to rescale the interval and/or weight function, depending on the type. GaussianProductRule takes a sequence of pairs (produced by GaussianQuadraturePairs) and returns a tensor array of abscissa/weight tuples that can be used for multidimensional Gaussian quadrature.

Status (August 2026, v15): working — repaired August 2026 (the old default tripped over $MachinePrecision no longer being an integer). Largely superseded by NIntegrate's Gaussian rules, though GaussianProductRule remains a convenience.

PartialEvaluation

The file PartialEvaluation.m contains the code for PartialEvaluation, a debugging tool. PartialEvaluation[f[args], n] evaluates the first n expressions in the "main" CompoundExpression in f[args]. (The position of the "main" CompoundExpression can be specified by an option.) An arbitrary expression can be appended as an optional third argument: PartialEvaluation[f[args], n, expr].

Status (August 2026, v15): still works.

DifferentialEvolution

(Note: Differential evolution is built into version 5.0 of Mathematica as an option to NMinimize.)

The package DifferentialEvolution.m implements a genetic algorithm for optimization. The algorithm is due to Kenneth Price and Rainer Storn (Dr. Dobb's Journal, April 1997).

The algorithm starts with a randomly chosen population of n real vectors, each with d >= 2 components. A cost function is given. (Cost is "negative fitness.") The cost of each member of the current population is determined. Each member then becomes a "target." The target is "mated" with a noisy vector randomly constructed from other members of the current generation to produce an offspring. The offspring replaces the target in the next generation if its cost is lower.

The mate is the sum of a "base" vector (whose construction is described below) and the scaled difference between two randomly chosen vectors. (The scale is given by the "weighting factor.") The offspring is constructed from the target and the mate by randomly choosing "genes" (i.e. components) from either the target or the mate. The probability that a gene comes from the mate is determined by the "cross-over rate." (At least one gene always comes from the mate, even if the cross-over rate is zero.) There are two ways to choose the base vector: (1) the base vector is chosen randomly from the current generation; (2) the base vector is a linear combination of the target and the "best" vector of the current generation (in terms of cost). The linear combination is determined by the "use-best weighting factor."

There is no convergence criterion built in. One simply runs the algorithm for a given number of generations. Convergence could be based on the dispersion of the costs or the population.

Status (August 2026, v15): still runs, as it happens — but superseded, as noted above, by NMinimize since Version 5.0.


Back to
Home page for Mark Fisher