コード例 #1
0
    private static void benford_pdf_test()

//****************************************************************************80
//
//  Purpose:
//
//    BENFORD_PDF_TEST tests BENFORD_PDF.
//
//  Licensing:
//
//    This code is distributed under the GNU LGPL license.
//
//  Modified:
//
//    26 February 2016
//
//  Author:
//
//    John Burkardt
//
    {
        int    n;
        double pdf;

        Console.WriteLine("");
        Console.WriteLine("BENFORD_PDF_TEST");
        Console.WriteLine("  BENFORD_PDF evaluates the Benford PDF.");

        Console.WriteLine("");
        Console.WriteLine("       N          PDF(N)");
        Console.WriteLine("");

        for (n = 1; n <= 9; n++)
        {
            pdf = Benford.benford_pdf(n);
            Console.WriteLine("  " + n.ToString(CultureInfo.InvariantCulture).PadLeft(6)
                              + "  " + pdf.ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }

        Console.WriteLine("");
        Console.WriteLine("       N          PDF(N)");
        Console.WriteLine("");

        for (n = 10; n <= 99; n++)
        {
            pdf = Benford.benford_pdf(n);
            Console.WriteLine("  " + n.ToString(CultureInfo.InvariantCulture).PadLeft(6)
                              + "  " + pdf.ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }
    }
コード例 #2
0
    public static void benford_test( )

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    BENFORD_TEST tests BENFORD.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    02 June 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int i;

        Console.WriteLine("");
        Console.WriteLine("BENFORD_TEST");
        Console.WriteLine("  BENFORD(I) is the Benford probability of the");
        Console.WriteLine("  initial digit sequence I.");
        Console.WriteLine("");
        Console.WriteLine("     I  BENFORD(I)");
        Console.WriteLine("");

        for (i = 1; i <= 9; i++)
        {
            Console.WriteLine("  "
                              + i.ToString().PadLeft(4) + "  "
                              + Benford.benford_pdf(i).ToString(CultureInfo.InvariantCulture).PadLeft(10) + "");
        }
    }
コード例 #3
0
    private static void benford_cdf_test()

//****************************************************************************80
//
//  Purpose:
//
//    BENFORD_CDF_TEST tests BENFORD_CDF.
//
//  Licensing:
//
//    This code is distributed under the GNU LGPL license.
//
//  Modified:
//
//    03 March 2016
//
//  Author:
//
//    John Burkardt
//
    {
        double cdf;
        int    n;
        double pdf;

        Console.WriteLine("");
        Console.WriteLine("BENFORD_CDF_TEST");
        Console.WriteLine("  BENFORD_CDF evaluates the Benford CDF.");

        Console.WriteLine("");
        Console.WriteLine("       N          CDF(N)          CDF(N) by summing");
        Console.WriteLine("");

        double cdf2 = 0.0;

        for (n = 1; n <= 9; n++)
        {
            cdf   = Benford.benford_cdf(n);
            pdf   = Benford.benford_pdf(n);
            cdf2 += pdf;
            Console.WriteLine("  " + n.ToString(CultureInfo.InvariantCulture).PadLeft(6)
                              + "  " + pdf.ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + cdf.ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + cdf2.ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }

        Console.WriteLine("");
        Console.WriteLine("       N          CDF(N)          CDF(N) by summing");
        Console.WriteLine("");

        cdf2 = 0.0;
        for (n = 10; n <= 99; n++)
        {
            cdf   = Benford.benford_cdf(n);
            pdf   = Benford.benford_pdf(n);
            cdf2 += pdf;
            Console.WriteLine("  " + n.ToString(CultureInfo.InvariantCulture).PadLeft(6)
                              + "  " + pdf.ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + cdf.ToString(CultureInfo.InvariantCulture).PadLeft(14)
                              + "  " + cdf2.ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }
    }