2 ms·
I agree. They seem to have greatly overestimated the expected number of back-to-back female songs. I too did a quick simulation and my numbers are close to your
by tzs 3y ago
I agree. They seem to have greatly overestimated the expected number of back-to-back female songs. I too did a quick simulation and my numbers are close to yours, and close to the radio station data in the article. My code is appended below.
Usage is "./bb.pl num_songs percent_by_women". E.g., "./bb_pl 100000 11" would do a 100000 song playlist where 11% of the songs are by women. Here was the output of a run with those arguments:
79227 MM, 1228 FF
9772 MF, 9772 FM
79.23% MM, 1.23% FF
9.77% MM, 9.77% FF
The first pair of output lines is saying that 79227 songs were songs by males (M) played immediately after an M song, 1228 songs were songs by females (F) played immediately after an F song, 9772 were F songs played immediately after an M song, and 9772 were M songs played immediately after an F song.
The second pair of output lines gives those as percentages of total songs.
#!/usr/bin/env perl
use strict;
use List::Util;
my $T_plays = shift @ARGV || die "Args: num_songs percent_by_women\n";
my $F_percent = shift @ARGV || die "Args: num_songs percent_by_women\n";
my $F_plays = int($T_plays * $F_percent / 100 + 0.5);
my $M_plays = $T_plays - $F_plays;
my @slot;
push @slot, 'M' foreach 1..$M_plays;
push @slot, 'F' foreach 1..$F_plays;
@slot = List::Util::shuffle @slot;
my $prior = '';
my $MM = 0;
my $FF = 0;
my $MF = 0;
my $FM = 0;
foreach (@slot) {
if ($_ eq $prior) {
if ($_ eq 'M') { ++$MM; }
else { ++$FF; }
} elsif ($prior ne '') {
if ($_ eq 'M') { ++$FM; }
else { ++$MF; }
}
$prior = $_;
}
print "$MM MM, $FF FF\n";
print "$MF MF, $FM FM\n";
print "\n";
printf "%.2f%% MM, %.2f%% FF\n", 100*$MM/$T_plays, 100*$FF/$T_plays;
printf "%.2f%% MM, %.2f%% FF\n", 100*$MF/$T_plays, 100*$FM/$T_plays;