Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


glenkzg

3 posts

Wannabe Geek


#173652 31-May-2015 13:55
Send private message

Hi, I need your help please.

I don't know computer programming or mathematics.
All I want is a simple PHP code for the following natural logarithm.

ln((N+1)/X)

and then a code to convert the natural logarithm to a percentile, as below.

 

(1 - exp (-L) ) * 100

I would have thought this would have been quite simple, but my web developers can't seem to get right.
I need your help urgently, I am desperate to get my website up and running and these calculations are critical.

Any help you can provide would be greatly appreciated.

Thanks in advance for all your help.

Glen

Create new topic
roobarb
701 posts

Ultimate Geek
+1 received by user: 643

Trusted

  #1315110 31-May-2015 14:20
Send private message

I'll bite.. firstly I am not a PHP programmer!

So the first part ln should convered by log

http://php.net/manual/en/function.log.php

The second part, the exp should covered by exp.

http://php.net/manual/en/function.exp.php

Are they interpreting your specification differently?

Have you given them sample results including the intermediate value L to validate against?

Are the developers using floating point values throughout the calculation?



glenkzg

3 posts

Wannabe Geek


  #1315115 31-May-2015 14:33
Send private message


Hi
Thanks heaps for your reply. As I said in OP I know nothing at all on this subject, that's why I'm paying web developers but they don't seem to be getting it right.

ln ((N+1)/X)

N= Number of players
X = players finishing position.

 

(1 - exp (-L) ) * 100

L = Average of all Log scores

 


I have no idea if the developers are using floating point values throughout the calculation. I'm sorry for being so vague but this is about the extent of my knowledge on the topic.

I've paid these guys heaps and I'd expect they it should be relatively simple for them to write this code (everything else they have done is brilliant, except for getting this equation to work).

Thanks
Glen

Critter
23 posts

Geek
+1 received by user: 1


  #1315192 31-May-2015 17:48
Send private message

I can help with PHP but not sure about the maths...

As obviously written as I can:

<?php
$n = 100;
$x = 15;
$result = log(($n+1)/$x);
echo "Log: {$result}";
echo "<br>";
$l = 1.5; // ??
$result = (1 - exp(-$l)) * 100;
echo "Result: {$result}";

Outputs:
Log: 1.907070315739
Result: 77.686983985157

Is that what you are looking for?
You should be able to see how that works, let me know if the equations are not correct.
These functions return floating point values, you may want to check out the accuracy of them depending on your application. E.g.: http://php.net/manual/en/language.types.float.php



glenkzg

3 posts

Wannabe Geek


#1315199 31-May-2015 18:12
Send private message

Hi Critter
That's awesome!!! cool
They're the outputs I'm wanting, I'll pass on the code to my developer.
Thanks heaps!!


Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.