<commit_before>#include <math.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>

bool in_circle(double x, double y, double radius) {
    return x * x + y * y < radius * radius;
}

void monte_carlo(int samples) {
    double radius = 1.0;
    int count = 0;

    for (int i = 0; i < samples; ++i) {
        double x = (double)rand() * 2.0 / RAND_MAX - 1.0;
        double y = (double)rand() * 2.0 / RAND_MAX - 1.0;

        if (in_circle(x, y, radius)) {
            count += 1;
        }
    }

    double estimate = 4.0 * count / (samples * radius * radius);

    printf("The estimate of pi is %f\n", estimate);
    printf("Which has an error of %0.2f%\n", 100 * (M_PI - estimate) / M_PI);
}

int main() {
    srand(time(NULL));

    monte_carlo(1000000);

    return 0;
}<commit_msg>fixing percentage error in monte_carlo.c (#374)<commit_after>#include <math.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>

bool in_circle(double x, double y, double radius) {
    return x * x + y * y < radius * radius;
}

void monte_carlo(int samples) {
    double radius = 1.0;
    int count = 0;

    for (int i = 0; i < samples; ++i) {
        double x = (double)rand() * 2.0 / RAND_MAX - 1.0;
        double y = (double)rand() * 2.0 / RAND_MAX - 1.0;

        if (in_circle(x, y, radius)) {
            count += 1;
        }
    }

    double estimate = 4.0 * count / (samples * radius * radius);

    printf("The estimate of pi is %f\n", estimate);
    printf("Percentage error: %0.2f%\n", 100 * fabs(M_PI - estimate) / M_PI);
}

int main() {
    srand(time(NULL));

    monte_carlo(1000000);

    return 0;
}
{'fraction_non_alphanumeric': 0.16165865384615385, 'fraction_numerical': 0.03545673076923077, 'mean_word_length': 2.425925925925926, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '931272', 'n_tokens_mistral': 681, 'n_tokens_neox': 621, 'n_words': 178}