Just an extension to Jake's answer by implementing the functions in lua. There is some fussing around to convert to and from pgfplots numerical representation (which probably isn't quite correct). Also a different approximation for the beta function is used:
\documentclass[tikz,border=5]{standalone}
\usepackage{pgfplots}
{\catcode`\~=11 \gdef\tilde{~}}
{\catcode`\%=11 \gdef\percent{%}}
\directlua{%
function lua2pgfplots(v)
if v \tilde= v then
return "3Y0e0]"
end
if v == math.huge then
return "4Y0e0]"
end
if v == -math.huge then
return "5Y0e0]"
end
if v == 0 then
return "0Y0e0]"
end
if v > 0 then
return string.format("1Y\percent e]", v)
else
return string.format("2Y\percent e]", v)
end
end
function pgfplots2lua(v)
local f, x
f, x = string.match(v, "(\percent d)Y(.*).")
f = tonumber(f)
x = tonumber(x)
if f == 1 then
return x
end
if f == 2 then
return -x
end
if f == 3 then
return 0/0
end
if f == 4 then
return math.huge
end
if f == 5 then
return -math.huge
end
return x
end
}
\directlua{
function beta(x,y)
return math.sqrt(2*math.pi)*(math.pow(x,x-.5)*math.pow(y,y-.5)) /
math.pow(x+y, x+y-.5)
end
function fdist(x, d1, d2)
return 1/beta(d1/2,d2/2)*math.pow(d1/d2, d1/2) *
math.pow(x, d1/2-1) *
math.pow(1+d1/d2*x, -(d1+d2)/2)
end
}
\pgfmathdeclarefunction{fdist}{3}{%
\edef\pgfmathresult{%
\directlua{%
local f
f = fdist(pgfplots2lua("#1"),pgfplots2lua("#2"),pgfplots2lua("#3"))
f = lua2pgfplots(f)
tex.print(f)
}%
}%
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=left,
enlargelimits=upper,
samples=100,
xmin=0, ymin=0,
domain=0.01:4,
legend cell align=left
]
\addplot [very thick, red] {fdist(x,1,1)}; \addlegendentry{$d_1=1,\hphantom{00} d_2=1$}
\addplot [very thick, black] {fdist(x,2,1)}; \addlegendentry{$d_1=2,\hphantom{00} d_2=1$}
\addplot [very thick, blue] {fdist(x,5,2)}; \addlegendentry{$d_1=5,\hphantom{00} d_2=2$}
\addplot [very thick, green] {fdist(x,10,1)}; \addlegendentry{$d_1=10,\hphantom{0} d_2=1$}
\addplot [very thick, gray] {fdist(x,100,100)}; \addlegendentry{$d_1=100, d_2=100$}
\end{axis}
\end{tikzpicture}
\end{document}

fdst(\x,\n,\m))=where you have an extra). With this change things compile even though there are still other mismatches lingering. For example I am unable to locate the opening(to match the closing one in)*exp. – Peter Grill Sep 25 '14 at 15:01