function outcome=fg(length,maxfg,pmaxfggood,midprobpoint,gimmeyardage) % outcome=1 if good, 0 otherwise % length=length of attempt % maxfg=maximum length for an attempt % pmaxfggood=prob of making a FG of length maxfg % midprobpoint=yardage at which prob of making FG is halfway between 1 and pmaxfggood % gimmeyardage=yardage at which prob of making the FG equals 1 if length <= gimmeyardage outcome=1; elseif length <= midprobpoint slope=.5*(1-pmaxfggood)/(midprobpoint-gimmeyardage); p=1-slope*(length-gimmeyardage); if rand < p outcome=1; else outcome=0; end else slope=.5*(1-pmaxfggood)/(maxfg-midprobpoint); p=.5*(1+pmaxfggood)-slope*(length-midprobpoint); if rand < p outcome=1; else outcome=0; end end