Jump to content

advanced math equations


dzhax

Recommended Posts

Hey guys I have a tough situation here. I am working on a project for a site built around ranking mma fighters.We have the site done but we need to write the script to determine rank.A friend of mine hooked me up with someone who created a formula for determining rank. This was great! The only problem was I don't understand how to turn it all into something php can calculate.Here is the formula: mmaRanking.pdfAny help on this is much appriciated. I would just put the above in code tags but i cant seems to get the formulas out of the pdf he sent me.-----Not sure if this is allowed but I am willing to pay for it to be converted to a working php script ready to be fed data.^let me know about this if so I will remove this.

Link to comment
Share on other sites

It would be good, if you would specify where you are unable to understand. we will try to help you to figure it out. if there is any code you have come up with already you can paste it too.

Link to comment
Share on other sites

oops my bad. its late and kind of in a hurry to get this done sryi got to the first 2 equations

<?/* MMA ALGORYTHM */$k0 = ''; //number of wins by knockout or submission$k1 = ''; //number of losses by knockout or submission$t0 = ''; //number of wins by TKO$t1 = ''; //number of losses by TKO$y0 = ''; //number of wins by decision$y1 = ''; //number of losses by decision$draws = ''; //8 lookin symbol - number of draws//Bf is the weighted sum of fighter f's wins$Bf = 1.15*$k0+$t0+0.85*$y0;//Hf is fighter f's weighted winning percentage$Hf = (1.5*$k0+$t0+0.5*$y0+0.1*$draws)/(1.5($k0+$k1)+($t0+$t1)+0.5($y0+$y1)+0.1*$draws);?>

Some email communication that I clarified with the writer of the formulaEmail from me to the formula creator

Is it possible to simplify the last 2 equations? I need to convert them into something that php can understand and compute. Even if it has to be a couple extra calculations to get the same result. Also the last 2 equations contain 2 different Fs. I assume the capital F is a value captured from the opponent and the italic f is for the current fighter. Also I want to make sure I did not ruin the calculation when making variables for the values.you have K0 = number of wins by knockout or submission. So if the number of knockouts is 3 then that value is simply 3 then right?
His response
I attached a psuedocode version of the document that I sent earlier. If that doesn't help to clarify, then let me know. Sorry for the f, F notation. Your assumption is correct. Capital F denotes the given fighter, and script f denotes one of capital F's opponents (script f is an element of theta(capital F), and theta(F) represents the set of opponents of F).And, yes, if a fighter knocks out his opponent 5 different times, and he gets knocked out twice, then his value for kappa_0 is 5, and his kappa_1 is 2.
attached file:
#include <math.h>class Fighter {public:	Fighter(int numOpps){		numOpponents = numOpps;		opponent = new Fighter*[numOpponents];	}	Fighter **opponent;	int numOpponents;	int kappa0,kappa1,tau0,tau1,gamma1,gamma0,delta;};double beta(Fighter *f){	return 1.15*(double)f->kappa0 + (double)f->tau0 + 0.85*(double)f->gamma0;}double littleLambda(Fighter *f){	return ( (1.5*(double)f->kappa0 + 0.5*(double)f->gamma0 + 0.1*(double)f->delta) / 					 ( 1.5*(double)(f->kappa0 + f->kappa1) + (double)(f->tau0 + f->tau1) + 						 0.5*(double)(f->gamma0+f->gamma1) + 0.1*(double)f->delta ) );}double sigma(double x){	return log(10.0 * x + 12.0) / 6.5;}double omega(Fighter *f){	return 0.6*sigma(beta(f)) + 0.4*littleLambda(f);}double bigLambda(Fighter *f){	double lambda = 0;	for(int i=0; i < f->numOpponents; i++){		lambda+=omega(f->opponent[i]);	}	return lambda/(double)f->numOpponents;}double rho(Fighter *f){	double rhoStep1 = 0;	for(int i=0; i < f->numOpponents; i++)		rhoStep1+=bigLambda(f->opponent[i]);	rhoStep1/=(double)f->numOpponents;	return 0.65*omega(f) + 0.25*bigLambda(f) + 0.1*rhoStep1;}

ugh its in C or C++ :) i fail at C

Link to comment
Share on other sites

When you have a sum (represented as a capital sigma) in math, it's translated to a loop in programming, where on each iteration you sum another value to a certain variable.

Link to comment
Share on other sites

this is the function sigma()

function sigma($x){return log(($x*=10)+12)/6.5;}

in the next equation of omega_f, you have to use the sigma($beta_f) passing the $beta_f as argumentfrom the doc..it looks likeYou need to make another function (capital_lamda_f()) which will create the avarage of wiiehted wins of oponents fighterin that function you need to sum the wiehted win (omega_f) of oponents then divide the number of oponents to get the avarage.the final ranking function phi_f() is relatively simple. you need to only use those functions and other variables according to it to get the result.

Link to comment
Share on other sites

i didnt know C was so similar to php math operations. all the doubles throw me off and not knowing the names of the math symbols is also hurting me.

//Bf is the weighted sum of fighter f's wins$Bf = 1.15*$k0+$t0+0.85*$y0;//Hf is fighter f's weighted winning percentage$Hf = (1.5*$k0+$t0+0.5*$y0+0.1*$draws)/(1.5($k0+$k1)+($t0+$t1)+0.5($y0+$y1)+0.1*$draws);//O(x) is a logarithmic weighting function used to map Bf to a value between 0 and 1. This gives a fighter with few wins significantly less credit than a fighter with many wins. However, for two fighters who have a similar number of wins, and they’ve both won many fights, their scores from this criterion will be very similar.function sigma($x){	return log(($x*=10)+12)/6.5;}//Wf is a linear combination of fighter f’s weighted winning percentage, and the remapped and weighted win total.$Wf = 0.6*sigma($Bf)+.04*$Hf;//Let O(F) the overall score for a fighter F. Then, A(F) is the average Wx for all of the opponents of fighter F.function A($F){	return ();}// p(F), the overall score for a fighter F, is a linear combination of Wf(the fighters winning score), A(F)(the fighter's opponents' average winning score), and the average winning score of the fighter's opponents'. Rank fighters based on their value of p(F).

Link to comment
Share on other sites

double is the data type.data type of function parameter and return value must be specfied in C. where as in php you dont need to worry about it. it is being automaticaly determined by php.

Link to comment
Share on other sites

does anyone know what this part is?

class Fighter {public:	Fighter(int numOpps){		numOpponents = numOpps;		opponent = new Fighter*[numOpponents];	}	Fighter **opponent;	int numOpponents;	int kappa0,kappa1,tau0,tau1,gamma1,gamma0,delta;};

it looks like the part that defines the variables.I have the following:

Fighter(int numOpps){		numOpponents = numOpps;		opponent = new Fighter*[numOpponents];	}	Fighter **opponent;	$numOpponents = '';	$kappa0 = '';	$kappa1 = '';	$tau0 = '';	$tau1 = '';	$gamma1 = '';	$gamma0 = '';	$delta = '';

but i don't think it is quite right. specifically the

Fighter(int numOpps){		numOpponents = numOpps;		opponent = new Fighter*[numOpponents];	}	Fighter **opponent;

I have rewritten the code by removing all of the doubles and adding function to the beginning of the equations.

Fighter(int numOpps){		numOpponents = numOpps;		opponent = new Fighter*[numOpponents];	}	Fighter **opponent;	$numOpponents = '';	$kappa0 = '';	$kappa1 = '';	$tau0 = '';	$tau1 = '';	$gamma1 = '';	$gamma0 = '';	$delta = '';function beta(Fighter *f){	return 1.15*$f->$kappa0 + $f->$tau0 + 0.85*$f->$gamma0;}function littleLambda(Fighter *f){	return ( (1.5*f->$kappa0 + 0.5*f->$gamma0 + 0.1*f->$delta) /					 ( 1.5*(f->$kappa0 + f->$kappa1) + (f->$tau0 + f->$tau1) +						 0.5*(f->$gamma0+f->$gamma1) + 0.1*f->$delta ) );}function sigma(double x){	return log(10.0 * x + 12.0) / 6.5;}function omega(Fighter *f){	return 0.6*sigma(beta(f)) + 0.4*littleLambda(f);}function rho(Fighter *f){	rhoStep1 = 0;	for(int i=0; i < f->numOpponents; i++)		rhoStep1+=bigLambda(f->opponent[i]);	rhoStep1/=f->numOpponents;	return 0.65*omega(f) + 0.25*bigLambda(f) + 0.1*rhoStep1;}

Link to comment
Share on other sites

i don't think you need to be casting the type in the function constructor either. just defining the name of the incoming parameter. i.e

function omega(fighter){	return 0.6*sigma(beta(fighter)) + 0.4*littleLambda(fighter);}

PHP is not a strictly typed language like C and Java, and as such you don't have to cast each variable like that.it might make more sense to make this a class, and then reference littleLambda and sigma using this->. just a thought.

Link to comment
Share on other sites

It's going to be difficult for you to translate C into PHP without knowing anything about C. The Fighter class you were looking at contains a few pointers and references, which don't translate to PHP perfectly. Some of them are unnecessary, with PHP you don't need to tell it how big to create an array, for example, because arrays in PHP can grow dynamically. Arrays in C are set at a certain size. That's what this says:opponent = new Fighter*[numOpponents];That says to create an array of Fighter objects, where the array is actually just a bunch of references or pointers instead of the actual objects, and the array can contain numOpponents items. That is an array definition in C. Something like this:function beta(Fighter *f){is a function which takes a pointer to a Fighter object as a parameter. Not an actual Fighter object, but a pointer to one. That's what the asterisk means. It's not necessary to do that in PHP, you don't need to pass references around and dereference everything like you do with C.

Link to comment
Share on other sites

I think im in over my head here... Just thinking about how I will calculate all of this is mind boggling.This is what i have does anyone see any errors?

$numOpponents = '';	$kappa0 = ''; //number of wins by knockout or submission	$kappa1 = ''; //number of losses by knockout or submission	$tau0 = '';   //number of wins by TKO	$tau1 = '';   //number of losses by TKO	$gamma1 = ''; //number of wins by decision	$gamma0 = ''; //number of losses by decision	$delta = '';  //8 lookin symbol - number of drawsfunction beta($fighter){	return (1.15*$fighter->$kappa0 + $fighter->$tau0 + 0.85*$fighter->$gamma0);}function littleLambda($fighter){	return ( (1.5*$fighter->$kappa0 + 0.5*$fighter->$gamma0 + 0.1*$fighter->$delta) / ( 1.5*($fighter->$kappa0 + $fighter->$kappa1) + ($fighter->$tau0 + $fighter->$tau1) + 0.5*($fighter->$gamma0+$fighter->$gamma1) + 0.1*$fighter->$delta ) );}function sigma($x){	return (log(10.0 * $x + 12.0) / 6.5);}function omega($fighter){	return (0.6*sigma(beta($fighter)) + 0.4*littleLambda($fighter));}function rho($fighter){	$rhoStep1 = 0;	for(int i=0; i < $fighter->$numOpponents; i++){		$rhoStep1+=bigLambda($fighter->$opponent[i]);	}	$rhoStep1/=$fighter->$numOpponents;	return (0.65*omega($fighter) + 0.25*bigLambda($fighter) + 0.1*$rhoStep1);}

i dont understand where $fighter comes from.and i would assume this would need to be looped to get the info

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...