m is the distance in trait value
e between optimal value and pop mean
σ is the standard dev of trait value distributions in the pop
k is the steepness of the trait to condition function
s is the survival parameter
a is max female fecundity
g is the strength of sexual selection
t is the size of competing groups of males
r is the number of repeted fitness measures for each male
d is the resolution of the condition to fitness function for males, i.e. how many focal individuals did we consider to draw that curve.

m=0;
σ=1;
k=5;

a=50;
g=10;
t=10;
r=25;
d=10;

Distribution of trait values, condition, condition after survival.

f[z_,m_,σ_]:=   ((E^( ((-1)/2) (((((z-m)/σ)))^2)))/(σ(Sqrt[2π])))
cond[z_,k_]:=(E^(-(((z))^2)/k))
invcond1[c_,k_]:=-(Sqrt[k]) (Sqrt[Log[(1/c)]])
invcond2[c_,k_]:=(Sqrt[k]) (Sqrt[Log[(1/c)]])
fcond[c_,m_,σ_,k_]:=(f[invcond1[c,k],m,σ]+f[invcond2[c,k],m,σ])*((Sqrt[k])/(2 c (Sqrt[Log[(1/c)]])))
surv[c_,s_]:=c(s+1)/(s+c)
marginalsurv[c_,m_,σ_,k_,s_]:=fcond[c,m,σ,k]*surv[c,s]
fcad[c_,m_,σ_,k_,s_]:=((marginalsurv[c,m,σ,k,s])/(NIntegrate[marginalsurv[cc,m,σ,k,s],{cc,0,1}]))

Male female covariance in fitness

covarmf[res_,rep_,g_,t_,m_,s_]:=(
Conditions={};
Densities={};
For[
i=1,
i≤res-1,
i++,
AppendTo[Conditions,(i+0.5)/res];
AppendTo[Densities,NIntegrate[fcond[c,m,σ,k],{c,i/res,(i+1)/res}]];
];
fc=ProbabilityDistribution[fcond[c,m,σ,k],{c,0,1}];

malefit=Table[Mean[Table[((Conditions[[i]]^g )/(Conditions[[i]]^g+Total[RandomVariate[fc,t-1]^g]))    *t*surv[Conditions[[i]],s],rep]],{i,1,res-1}];


femfit=Table[Conditions[[i]]*a*surv[Conditions[[i]],s],{i,1,res-1}];

meanmalefitness=Densities.malefit;
meanfemfitness=Densities.femfit;
covar=Densities.((malefit-meanmalefitness)*(femfit-meanfemfitness));
covarrelative=covar/(meanmalefitness*meanfemfitness);
covarrelative)

Males variance in relative fitness

res=50;
rep=2;
g=1;
m=2;
t=2;

varmales[res_,rep_,g_,t_,m_,s_]:=(
Conditions={};
Densities={};
For[
i=1,
i≤res-1,
i++,
AppendTo[Conditions,(i+0.5)/res];
AppendTo[Densities,NIntegrate[fcond[c,m,σ,k],{c,i/res,(i+1)/res}]];
];
fc=ProbabilityDistribution[fcond[c,m,σ,k],{c,0,1}];

malefit=Table[Mean[Table[((Conditions[[i]]^g )/(Conditions[[i]]^g+Total[RandomVariate[fc,t-1]^g]))    *t*surv[Conditions[[i]],s],rep]],{i,1,res-1}];



meanmalefitness=Densities.malefit;
varmalefitness=Densities.(malefit-meanmalefitness)^2;
varmalerelative=varmalefitness/(meanmalefitness)^2;
varmalerelative)

Females variance in relative fitness

varfem[res_,a_,b_,m_,s_]:=(
Conditions={};
Densities={};
For[
i=1,
i≤res-1,
i++,
AppendTo[Conditions,(i+0.5)/res];
AppendTo[Densities,NIntegrate[fcond[c,m,σ,k],{c,i/res,(i+1)/res}]];
];

femfit=Table[Conditions[[i]]^b*a*surv[Conditions[[i]],s],{i,1,res-1}];

meanfemfitness=Densities.femfit;
varfemfitness=Densities.(femfit-meanfemfitness)^2;
varfemrelative=varfemfitness/(meanfemfitness)^2;
varfemrelative)