Last active
June 8, 2026 00:56
-
-
Save alwynallan/eddc155dcf8a1c88240b782f19fddfd3 to your computer and use it in GitHub Desktop.
Group Preference Statistics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // (C) 2026 alwynallam@gmail.com, MIT License | |
| // $ gcc -Wall -O3 group_preference.c -o group_preference && ./group_preference | |
| // see https://www.pewresearch.org/social-trends/2017/05/18/1-trends-and-patterns-in-intermarriage/ | |
| // see https://news.harvard.edu/gazette/story/2026/06/why-are-white-black-marriage-rates-so-low/ | |
| #include <stdio.h> | |
| #include <stdint.h> | |
| #include <assert.h> | |
| double grand_f_0_1() { // https://stackoverflow.com/a/26867455 | |
| uint64_t bits; | |
| static FILE * ur = NULL; | |
| if(ur==NULL) ur=fopen("/dev/random", "rb"); | |
| assert(1 == fread(&bits, sizeof(bits), 1, ur)); | |
| return bits * 5.421010862427522170037264004349e-020; | |
| } | |
| int main() { | |
| const int marriages = 1000000; // perform matchmaking until | |
| const double p11 = 0.1; // probability that an individual in the majority group will find an individual in the majority group marriageable | |
| const double p12 = 0.1; // probability that an individual in the majority group will find an individual in the minority group marriageable | |
| const double p21 = 0.1; // probability that an individual in the minority group will find an individual in the majority group marriageable | |
| const double p22 = 0.1; // probability that an individual in the minority group will find an individual in the minority group marriageable | |
| const double p1 = 0.90; // proportion of the population in the majority group | |
| int marriage = 0; // count of marriages | |
| int marriage1 = 0; // count of marriages with at least one individual from group 1 | |
| int marriage2 = 0; // count of marriages with at least one individual from group 2 | |
| int intermarriage = 0; // count of marriages that have partners from different groups | |
| // assumption: marriage occurs when two candidates paired at random find each other marriageable | |
| while(marriage < marriages) { | |
| int candidate1 = (p1 < grand_f_0_1()) + 1; | |
| int candidate2 = (p1 < grand_f_0_1()) + 1; | |
| int match; | |
| if(candidate1 == 1 && candidate2 == 1) match = grand_f_0_1() < p11 && grand_f_0_1() < p11; | |
| else if(candidate1 == 2 && candidate2 == 2) match = grand_f_0_1() < p22 && grand_f_0_1() < p22; | |
| else match = grand_f_0_1() < p12 && grand_f_0_1() < p21; | |
| if(match) { | |
| marriage++; | |
| if(candidate1 == 1 || candidate2 == 1) marriage1++; | |
| if(candidate1 == 2 || candidate2 == 2) marriage2++; | |
| if(candidate1 != candidate2) intermarriage++; | |
| } | |
| } | |
| printf("Of %d marriages, %d are intermarriages (%.1lf%%)\n", marriage, intermarriage, (double)intermarriage / (double)marriage * 100.); | |
| printf("Of marriages with at least one partner from group 1, %.1lf%% will be intermarriages.\n", (double)intermarriage / (double)marriage1 * 100.); | |
| printf("Of marriages with at least one partner from group 2, %.1lf%% will be intermarriages.\n", (double)intermarriage / (double)marriage2 * 100.); | |
| return 0; | |
| } | |
| /* | |
| Findings: | |
| 1. The model is not sensitive to the overall pickiness of the individuals, it just takes longer to run | |
| 2. If the groups are equal size (p1=0.50), and the preference matrix is uniform, itermarriage is 50% | |
| If the majority is 90% of the population (p1=0.90) | |
| 3. and the preference matrix is uniform (pij=0.1), intermarriage is 18.0% | |
| 4. if majority individuals have a strong preference for majority partners (p11=0.2), intermarriage is 5.3% | |
| 5. if minority individuals have a strong preference for minority partners (p22=0.2), intermarriage is 17.5% | |
| 6. if all individuals have a strong preference for partners from the same group (p11=p22=0.2), intermarriage is 5.2% | |
| 7. if majority individuals have a strong aversion to minority partners (p12=0.05), intermarriage is 9.9% | |
| 8. if minority individuals have a strong aversion to majority partners (p21=0.05), intermarriage is 9.9% | |
| 9. if all individuals have a strong aversion to partners from the other group (p12=p21=0.05), intermarriage is 5.2% | |
| Note: Findings 6 and 9 are consistent with 1. | |
| 10. With the conditions of Finding 2, of marriages with at least one partner from a given group, 66.7% will be intermarriages. | |
| 11. With the conditions of Finding 3, of marriages with at least one partner from the majority, 18.2% will be intermarriages. Of | |
| marriages with at least one partner from the minority, 94.7% will be intermarriages. | |
| 12. With the conditions of Findings 4-9, of marriages with at least one partner from the minority, at least 80% will be intermarriages. | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment