private void MAKEDATA(ref double[,] _designmatrix, ref double[] _t, ref double[] _X) { var r = new RandomBoxMuller(); RandomMT rand = new RandomMT(1); for (int i = 0; i < CONST.N; i++) { _X[i] = rand.Double() * Math.PI * 2; _t[i] = System.Math.Sin(_X[i]) + r.next(); } for (int j = 0; j < CONST.N; j++) { for (int i = 0; i < CONST.M; i++) { _designmatrix[j, i] = System.Math.Pow(_X[j], i); if (i == 0) { _designmatrix[j, i] = 1; } } } }
//---------------------------------------------------------------------------------- static void predicted_Distribution_output(double[][] u, double[][,] V) { int Num = 300; //等高線描画用プロット数 int Ratio = 10000000; RandomMT rand = new RandomMT(); double[][] x_toukou = new double[Num][]; //等高線描画用プロット点 for (int m = 0; m < M; m++) { double[,] U; //直交固有ベクトル行列 double[] lambda; //固有値 Tuple<double[,], double[]> tu; tu = Mt.EigenValueDecompositionM(V[m]); lambda = tu.Item2; U = tu.Item1; bool sign_flag = true; for (int n = 0; n < Num; n++) { sign_flag = !sign_flag; double[] y = new double[2]; y[1] = 2.0 * Math.Sqrt(lambda[0] * Ratio) * rand.Double() - Math.Sqrt(lambda[0] * Ratio); //楕円の定義域内に if (sign_flag) y[0] = Math.Sqrt(lambda[1] * Ratio - y[1] * y[1] * lambda[1] / lambda[0]); //次元を逆にしたら上手く等高線が書けたが...たぶん直交行列Uの構成の仕方が原因 else y[0] = -Math.Sqrt(lambda[1] * Ratio - y[1] * y[1] * lambda[1] / lambda[0]); x_toukou[n] = Mt.Add(Mt.Mul(U.Inverse(), y), u[m]); } CsvFileIO.CsvFileIO.WriteData("x_toukou(M=" + m + ").csv", jagTomatrix(x_toukou)); } CsvFileIO.CsvFileIO.WriteData("mu_matrix.csv", jagTomatrix(u)); }
/// <summary> /// フレームごとに実行する処理(ロジック部分)を書く。 /// </summary> private void _update() { // エネミーの移動 foreach (var enemy in _enemies) { if (!enemy.IsAlive) { continue; } enemy.Update(_rand.Double()); if (enemy.Intersect(_player)) { enemy.Die(); } foreach (var bullet in _bullets) { if (enemy.Intersect(bullet)) { enemy.Die(); bullet.Die(); } } } // 弾の移動 foreach (var bullet in _bullets) { bullet.Update(); } // プレイヤーの移動 foreach (var key in _pressedKeys) { switch (key) { case Keys.Right: _player.X++; break; case Keys.Left: _player.X--; break; case Keys.Up: _player.Y--; break; case Keys.Down: _player.Y++; break; case Keys.Enter: if (!_createBullet) { _bullets.Add(new Bullet(_player.X, _player.Y, -90 * Math.PI / 180)); _createBullet = true; } break; default: break; } } }
//-------------------------------------------------------------------------------- //ガンマ分布に従う乱数生成 static double gamma_rnd(RandomMT rand, double shape, double scale) { double output; double input = rand.Double(); output = scale * Mt.InverseIncompleteGamma(input, shape); return output; }