Jump to content

Recommended Posts

I'd like to figure out how to  calculate the chance of success per a certain number of trails by a specific percentage.  Essentially, I'm trying to make a calculator for upgrading chances in an MMORPG.

 

The amount of trials is going to be captured via a form and then calculated by a specific percentage. I've already go that dealt with using a switch statement with my form and variables all together... It's just this equation. I have absolutely no clue where to begin.

 

For example,

I'd like to do something such as...

(.6 * .4 * .2 * .2) * 100 = 0.0096 (rate of success)

Then take the number of trials I have (100... 10... 5... or what have you)

And calculate the chance of hitting the 0.0096 success rate for those 100 chances.

Essentially, with a finished output of something like "Out of 100 tries, your chance of success is X%"

 

I think I need to be using Binomial Distribution, but I've got no idea. The only code out there I'm able to find out there is for Binomial Coefficient (which is helping me none).

 

Thanks for the help in advance. I'm TERRIBLE at math  :shrug:!

 

 

~ Miss Kinnati

Thanks so much for the reply! I've been trying to get this to work for a week!

 

This code here is nested within a switch statement.

I don't bother with creating a function until I get the base working.

 

$trials = 0; // Number of trials
$upgradeChance = 0; // Original percent rate of success
$rateSuccess = 0;  // Total rate of success

$rateSuccess = 1 - (1 - $upgradeChance) ^ $trials;
echo "Chance of Success: <b>$rateSuccess%</b><br>";

 

Basically in using your code I'm getting an entire printout of my contents of my switch. Rather amusing I do say... But... I have no idea why it's doing that.

 

I checked the manual and it looks like this is the right usage.

 

However, should I be taking and converting my numbers to binary here? From what I've read this is a bitwise operation, but according to the manual it can be used in this way...

 

No idea.

i wrote just pseudo code in pascal notation

php code looks like

$trials = 2; // Number of trials
$upgradeChance = 0.5; // Original percent rate of success 50%
$rateSuccess = 0;  // Total rate of success is 3 of 4

$rateSuccess = 1 - pow((1 - $upgradeChance), $trials) ;
echo "Chance of Success: <b>".$rateSuccess * 100 ."%</b><br>";

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.