Пример #1
0
    def show_stats(self, stats):
        """Shows statistics for the current quote."""
        results = stats.text_id_results(stats.tag, self.quote_id)

        if len(results) < 2:
            return

        percent = self.config.wpm.confidence_level
        assert (0.0 <= percent <= 1.0)
        alpha = 1.0 - percent
        samples = len(results)

        wpm_avg, acc_avg = results.averages()
        wpm_sd, acc_sd = results.stddevs()
        wpm_min, wpm_max, acc_min, acc_max = results.extremals()

        wpm_ci0, wpm_ci1 = confidence_interval(wpm_avg, wpm_sd, samples, alpha)
        wpm_pi0, wpm_pi1 = prediction_interval(wpm_avg, wpm_sd, alpha)

        acc_ci0, acc_ci1 = confidence_interval(acc_avg, acc_sd, samples, alpha)
        acc_pi0, acc_pi1 = prediction_interval(acc_avg, acc_sd, alpha)

        msg = "wpm %5.1f min %5.1f avg %5.1f max %5.1f sd %2d%% ci [%5.1f-%5.1f] [%5.1f-%5.1f] pi (n=%d)" % (
            wpm_min, wpm_avg, wpm_max, wpm_sd, 100 * percent, wpm_ci0, wpm_ci1,
            wpm_pi0, wpm_pi1, samples)
        self.cheight += 2
        self.addstr(0, self.cheight, msg, Screen.COLOR_CORRECT)

        msg = "acc %5.1f min %5.1f avg %5.1f max %5.1f sd %2d%% ci [%5.1f %5.1f] [%5.1f %5.1f] pi (n=%d)" % (
            100 * acc_min, 100 * acc_avg, 100 * acc_max, 100 * acc_sd,
            100 * percent, 100 * acc_ci0, 100 * acc_ci1, 100 * acc_pi0,
            100 * acc_pi1, samples)
        self.cheight += 1
        self.addstr(0, self.cheight, msg, Screen.COLOR_CORRECT)
        self.cheight += 1
Пример #2
0
def print_stats(stats):
    """Prints table of game results."""
    table = []

    config = wpm.config.Config()
    percent = config.wpm.confidence_level
    assert (0.0 <= percent <= 1.0)

    for tag in sorted(stats.games.keys()):
        name = tag if tag is not None else "n/a"

        for last_n in [0, 10, 50, 100, 500, 1000]:
            results = stats.results(tag, last_n=last_n)

            if len(results) >= last_n:
                if last_n == 0:
                    label = len(results)
                else:
                    label = "n-%d" % last_n

                wpm_avg, acc_avg = results.averages()
                wpm_sd, acc_sd = results.stddevs()

                alpha = 1.0 - percent
                wpm_ci = confidence_interval(wpm_avg, wpm_sd, len(results),
                                             alpha)
                wpm_pi = prediction_interval(wpm_avg, wpm_sd, alpha)

                table.append([
                    name, label, wpm_avg, wpm_sd, 100.0 * acc_avg,
                    100.0 * acc_sd, wpm_ci[0], wpm_ci[1], wpm_pi[0], wpm_pi[1]
                ])

    if table:
        width = max(max(len(e[0]) for e in table), 11)
    else:
        width = 0

    head0 = "Tag          Games    WPM                                     Accuracy"
    head1 = "                      avg     sd     %2d%% ci      %2d%% pi       avg     sd   " % (
        100 * percent, 100 * percent)

    print("=" * len(head1))
    print(head0)
    print(head1)
    print("-" * len(head1))

    for entry in table:
        label, count, wpm_avg, wpm_sd, acc_avg, acc_sd, ci0, ci1, pi0, pi1 = entry
        print(
            "%-*s   %6s  %5.1f  %5.1f   %5.1f-%5.1f %5.1f-%5.1f %5.1f%%  %5.1f%%"
            % (width, label, count, wpm_avg, wpm_sd, ci0, ci1, pi0, pi1,
               acc_avg, acc_sd))

    print("=" * len(head1))
Пример #3
0
def print_stats(stats, cpm):
    """Prints table of game results."""
    table = []

    config = wpm.config.Config()
    percent = config.wpm.confidence_level

    for tag in sorted(stats.games.keys()):
        name = tag if tag is not None else "n/a"

        for last_n in [0, 10, 50, 100, 500, 1000]:
            results = stats.results(tag, last_n=last_n)

            if len(results) >= last_n:
                if last_n == 0:
                    label = len(results)
                else:
                    label = "n-%d" % last_n

                avg, acc_avg = results.averages()
                sd, acc_sd = results.stddevs()

                if cpm:
                    avg = wpm_to_cpm(avg)
                    sd = wpm_to_cpm(sd)

                alpha = 1.0 - percent
                ci = confidence_interval(avg, sd, len(results), alpha)
                pi = prediction_interval(avg, sd, alpha)

                table.append([name,
                              label,
                              avg,
                              sd,
                              100.0*acc_avg,
                              100.0*acc_sd,
                              ci[0],
                              ci[1],
                              pi[0],
                              pi[1]])

    if table:
        width = max(max(len(e[0]) for e in table), 11)
    else:
        width = 0

    head0 = "Tag          Games    %s                                     Accuracy" % ("CPM" if cpm else "WPM")
    head1 = "                      avg     sd     %2d%% ci      %2d%% pi       avg     sd   " % (100*percent, 100*percent)

    if cpm:
        head0 += "            "
        head1 += "            "

    print("="*len(head1))
    print(head0)
    print(head1)
    print("-"*len(head1))

    for entry in table:
        label, count, avg, sd, acc_avg, acc_sd, ci0, ci1, pi0, pi1 = entry
        if cpm:
            print("%-*s   %6s  %7.1f  %7.1f   %7.1f-%7.1f %7.1f-%7.1f %5.1f%%  %5.1f%%" %
                  (width, label, count, avg, sd, ci0, ci1, pi0, pi1, acc_avg, acc_sd))
        else:
            print("%-*s   %6s  %5.1f  %5.1f   %5.1f-%5.1f %5.1f-%5.1f %5.1f%%  %5.1f%%" %
                  (width, label, count, avg, sd, ci0, ci1, pi0, pi1, acc_avg, acc_sd))

    print("="*len(head1))
Пример #4
0
def print_stats(stats, cpm):
    """Prints table of game results."""
    table = []

    config = wpm.config.Config()
    percent = config.wpm.confidence_level

    for tag in sorted(stats.games.keys()):
        name = tag if tag is not None else "n/a"

        for last_n in [0, 10, 50, 100, 500, 1000]:
            results = stats.results(tag, last_n=last_n)

            if len(results) >= last_n:
                if last_n == 0:
                    label = len(results)
                else:
                    label = "n-%d" % last_n

                avg, acc_avg = results.averages()
                sd, acc_sd = results.stddevs()

                if cpm:
                    avg = wpm_to_cpm(avg)
                    sd = wpm_to_cpm(sd)

                alpha = 1.0 - percent
                ci = confidence_interval(avg, sd, len(results), alpha)
                pi = prediction_interval(avg, sd, alpha)

                table.append([name,
                              label,
                              avg,
                              sd,
                              100.0*acc_avg,
                              100.0*acc_sd,
                              ci[0],
                              ci[1],
                              pi[0],
                              pi[1]])

    if table:
        width = max(max(len(e[0]) for e in table), 11)
    else:
        width = 0

    head0 = "Tag          Gajes    %s                                     Accuracy" % ("CPM" if cpm else "WPM")
    head1 = "                      avg     sd     %2d%% ci      %2d%% pi       avg     sd   " % (100*percent, 100*percent)

    if cpm:
        head0 += "            "
        head1 += "            "

    print("="*len(head1))
    print(head0)
    print(head1)
    print("-"*len(head1))

    for entry in table:
        label, count, avg, sd, acc_avg, acc_sd, ci0, ci1, pi0, pi1 = entry
        if cpm:
            print("%-*s   %6s  %7.1f  %7.1f   %7.1f-%7.1f %7.1f-%7.1f %5.1f%%  %5.1f%%" %
                  (width, label, count, avg, sd, ci0, ci1, pi0, pi1, acc_avg, acc_sd))
        else:
            print("%-*s   %6s  %5.1f  %5.1f   %5.1f-%5.1f %5.1f-%5.1f %5.1f%%  %5.1f%%" %
                  (width, label, count, avg, sd, ci0, ci1, pi0, pi1, acc_avg, acc_sd))

    print("="*len(head1))