File: axisxform.sl

package info (click to toggle)
slxfig 0.2.0~.138-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,196 kB
  • sloc: sh: 3,086; ansic: 598; makefile: 265; php: 6
file content (29 lines) | stat: -rw-r--r-- 590 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require ("xfig");
require ("rand");

private define wcs_func (x, cd)
{
   variable s = sign(x);
   return s*sqrt(s*x);
}

private define wcs_invfunc (x, cd)
{
   return sign(x)*x*x;
}

xfig_plot_add_transform ("sqrt", &wcs_func, &wcs_invfunc, NULL);

define slsh_main ()
{
   variable n = 100000;
   variable x = rand_gauss (1.0, n);
   x = x[array_sort(x)];
   variable c = cumsum(1+Double_Type[n]);
   c /= c[-1];
   variable w = xfig_plot_new ();
   w.xaxis(;wcs="sqrt",);
   w.yaxis(;wcs="cdf",);	       %  built-in method for CDFs
   w.plot (x, c);
   w.render ("axisxform.png");   
}