I have the following code from the numerical recipes in C which calculates the incomplete beta function using continuous fraction and Lentz method.
float beta