Ejemplo n.º 1
0
    private static void test11()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    TEST11 tests MWC_SEEDED.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    16 October 2013
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int j;

        Console.WriteLine("");
        Console.WriteLine("TEST11");
        Console.WriteLine("  MWC_SEEDED is a generator of pseudorandom uniformly");
        Console.WriteLine("  distributed unsigned 32 bit integers.");
        Console.WriteLine("");
        Console.WriteLine("       Input W       Input Z      Output W      Output Z  Output Value");
        Console.WriteLine("");

        int w_in = 345678912;
        int z_in = 456789123;

        for (j = 1; j <= 10; j++)
        {
            int w_old = w_in;
            int z_old = z_in;
            int value = MultiplyWithCarry.mwc_seeded(ref w_in, ref z_in);
            Console.WriteLine("  " + w_old.ToString().PadLeft(12)
                              + "  " + z_old.ToString().PadLeft(12)
                              + "  " + w_in.ToString().PadLeft(12)
                              + "  " + z_in.ToString().PadLeft(12)
                              + "  " + value.ToString().PadLeft(12) + "");
        }
    }
Ejemplo n.º 2
0
    public static int kiss_seeded(ref int jcong, ref int jsr, ref int w, ref int z)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    KISS_SEEDED evaluates the KISS random number generator.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    18 October 2013
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Reference:
    //
    //    George Marsaglia, Wai Wan Tsang,
    //    The Ziggurat Method for Generating Random Variables,
    //    Journal of Statistical Software,
    //    Volume 5, Number 8, October 2000, seven pages.
    //
    //  Parameters:
    //
    //    Input/output, uint32_t &JCONG, uint32_t &JSR, uint32_t &W, uint32_t &Z,
    //    the seeds, which are updated on each call.
    //
    //    Output, uint32_t KISS_SEEDED, the new value.
    //
    {
        int value = (MultiplyWithCarry.mwc_seeded(ref w, ref z) ^ Congruential.cong_seeded(ref jcong)) + SHR3.shr3_seeded(ref jsr);

        return(value);
    }