public override distributions.Distribution expand(long[] batch_shape, distributions.Distribution instance = null) { if (instance != null && !(instance is Gamma)) { throw new ArgumentException("expand(): 'instance' must be a Chi2 distribution"); } if (instance == null) { instance = new Chi2(concentration); } return(base.expand(batch_shape, instance)); }
public void TestChi2() { double[] x = NP.Arange(0, 10); double[] y = NP.Broadcast((xx) => 2 * xx + 3, x); PDF linear = (v) => v[0] * v[1] + v[2]; Chi2 x2 = new Chi2(linear, x, y); double[] tmp = { 2, 3 }; Assert.AreEqual(0.0, x2.Compute(tmp)); double[] tmp2 = { 2, 4 }; Assert.AreEqual(10.0, x2.Compute(tmp2)); }