// g05tg Example Program Text // C# version, NAG Copyright 2008 using System; using NagLibrary; using System.Globalization; using System.IO; namespace NagDotNetExamples { public class G05TGE { static void Main(String[] args) { StartExample(); } public static void StartExample() { try { int genid, i, j, m, subid; int n=20; int k=4; int lr=6007; double[] p = new double[k]; double[] r = new double[lr]; int[] seed = new int[1]; int[,] x = new int[n, k]; int ifail; Console.WriteLine("g05tg Example Program Results"); Console.WriteLine(""); // Set the distribution parameters P and M p[0] = 0.080e0; p[1] = 0.10e0; p[2] = 0.80e0; p[3] = 0.020e0; m = 6000; // Initialise the seed seed[0] = 1762543; // genid and subid identify the base generator genid = 1; subid = 1; // Initialise the generator to a repeatable sequence G05.G05State g05State = new G05.G05State(genid, subid, seed, out ifail); if (ifail != 0) { Console.WriteLine(" ** Generator initialisation returned with ifail = {0,5}",ifail); goto L40; } // Generate the variates // Choose mode = 2 G05.g05tg(2, n, m, k, p,r, g05State, x, out ifail); if (ifail != 0) { Console.WriteLine(" ** G05.g05tg returned with ifail = {0,5}",ifail); goto L40; } // Display the variates for (i = 1 ; i <= n ; i++) { for (j = 1 ; j <= k ; j++) { Console.Write(" {0,8}", x[i - 1 , j - 1]); } Console.WriteLine(""); } // L40: ; // } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine( "Exception Raised"); } } } }