new file: cell2loc.py
[GalaxyCodeBases.git] / perl / etc / justonce / 20140324hw4.pl
blob45f492f3cd55d6e6780b6024515582d20d877fd9
1 #!/usr/bin/perl -w
2 use strict;
3 use warnings;
4 use Data::Dump;
6 #die "Usage: $0 <s> <t>\nW(AA), W(Aa) and W(aa) is 1-s, 1, 1-t respectively.\n" if @ARGV<2;
8 my @N = (1000,1000,100,1000,1000);
9 ddx \@N;
11 sub getNe($$) {
12 my ($m,$f) = @_;
13 my $Ne = 4*$m*$f/($m+$f);
14 return $Ne;
17 sub getPop($$) {
18 my ($Pm,$Pf) = @_;
19 my $mf = $Pm + $Pf;
20 my $sum = 0;
21 print STDERR '--- Ne: ';
22 for my $n ( @N ) {
23 my $Ne = getNe( $n*$Pm/$mf,$n*$Pf/$mf );
24 $sum += 1/$Ne;
25 print STDERR "$Ne, ";
27 print STDERR "\n";
28 $sum /= scalar @N;
29 return 1/$sum;
32 print STDERR "1:1\n",getPop(1,1),"\n";
34 print STDERR "1:4\n",getPop(1,4),"\n";