<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,38 @@
+//return an array of n 2d vectors
+function randn(n) {
+    var randn = NormalDistribution(1, 0);
+    var a = [];
+    for (i=0; i &lt; n; i++) {
+        a.push([randn.sample(), randn.sample()]);
+    }
+    return $M(a);
+}
+
+function NormalDistribution(sigma, mu) {
+    return new Object({
+        sigma: sigma,
+        mu: mu,
+        //Box-Muller Transform
+        sample: function() {
+            var res;
+            if (this.storedDeviate) {
+                res = this.storedDeviate * this.sigma + this.mu;
+                this.storedDeviate = null;
+            } else {
+                var dist = Math.sqrt(-1 * Math.log(Math.random()));
+                var angle = 2 * Math.PI * Math.random();
+                this.storedDeviate = dist*Math.cos(angle);
+                res = dist*Math.sin(angle) * this.sigma + this.mu;
+            }
+            return res;
+        },
+        sampleInt : function() {
+            return Math.round(this.sample());
+        }
+    });
+}
+
+
 function cholesky(a){
     var n =a.rows();
     var el = a.dup(); //MUST NOT use = operator - need a new matrix here!</diff>
      <filename>linalg/cholesky.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>13c3a41585e37348fde004b739fb20567d943cd8</id>
    </parent>
  </parents>
  <author>
    <name>Bill Mill</name>
    <email>bill.mill@gmail.com</email>
  </author>
  <url>http://github.com/llimllib/grabcut_js/commit/ea2eb9648809cd52cd8131f0f117bf08e6a1cf33</url>
  <id>ea2eb9648809cd52cd8131f0f117bf08e6a1cf33</id>
  <committed-date>2009-11-04T06:00:02-08:00</committed-date>
  <authored-date>2009-11-04T06:00:02-08:00</authored-date>
  <message>moving randn and cholesky to linalg</message>
  <tree>fe36775cec5c7a557f3d3a8458a37a3991024f5f</tree>
  <committer>
    <name>Bill Mill</name>
    <email>bill.mill@gmail.com</email>
  </committer>
</commit>
