How to achieve certain effects. Posts are mainly based on search keywords that visitors used and their necessity for psychological experiments. Posts generally assume MSIE (5.1 and up).
For certain experiments in psychology, especially those with tasks in which parameters are changed in response to the behavior of the subject ('adaptive testing'), it is useful to be able to minimize a function. DHTML is very useful for implementing such tasks (and an extemely cheap alternative for expensive experimentation software such as E-Prime), and so it is useful to have a javascript algorithm for function minimization. I found a useful C algorithm that was straightforward enough to translate into JavaScript (click the title of this post to download). It is an implementation of the Hooke and Jeeves algorithm (with improvements; read this for a conceptual explanation and comparison to other algorithms). Good things of this algorithm are: light weight and simple code, reasonably robust, multidimensional minimization, no gradients required, and open source. This javascript implementation is easy to use as the example below demonstrates:
<script type=text/javascript src="hooke.js"><script/>
<script>
function g(x, n) // x contains the parameters, n is the # of params
{
c = -Math.exp(-(4-x[0])*(4-x[0])) + (x[1]*x[1]);
return (c);
}
var console = document.getElementById("console")
var a = new Hooke(g); // new minimizer object
a.startpt = [5, 1.9]; // starting point
a.setConsole(console); // give a div element for diagnostic output
a.main(); // start searching
var result = a.endpt; // array containing the coordinates found
<script>
<div id=console></div>
We—that is, Eric-Jan Wagenmakers, Han van der Maas and me—have recently submited a paper which introduces the "EZ diffusion model" for two-choice reaction times, based on the diffusion model by Ratcliff (1978). To make application of the model easier we made a simple JavaScript program.
Here's a batch-processing version. You only have to paste a table with the means, variances and proportions correct, and click a button to compute the EZ-diffusion parameters. The values are nicely formatted in a table so that you can copy easily copy and paste them back into your data analysis program. The original program can be found on E-J's site.
Update: An updated version of the EZ diffusion model, EZ2, is now available which also estimates the starting point/bias parameter. See EZ2