ID:793611
 
(See the best response by Jazztoken.)
Code:
var/topnumber = 999**11000


Problem description:
I am working on a probability calculator and obviously have run into BYONDs limit into numbers. I've tried using the bignum library, but because it doesn't by default do exponents, I've tried doing a for(I=1,I<=11000,I++)topnumber = topnumber.multiply(topnumber) but it freezes pretty quick. Any suggestions on a work around or another language that could handle it?

P.S. I am predicting the probability of a single outcome of a 1000 possible outcome event that has already happened 11000 times. This is just one part of the equation.
999^100 is approximately 904792147113709042032214606239950000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000 0.

I doubt 999^11000 will even fit on one screen, assuming you could calculate it sometime this year.

Are you sure your equation is correct? Your value isn't even fractional...

If it hadn't been so long since I had done probabilities, I would try to point you in the right direction.

Also, is it the probability that the single outcome occurs exactly once, or at least once?
It has 32996 significant digits.

Why on earth do you need anything this precise? Are you trying to build a LHC in Byond?
Well basically there is a game that has 3 balls each with a value of 0 to 9. Totalling 1000 different possibilities. This game has been played 11000 times so far and is done twice a day. Probability formula states:

((possible outcomes)-(Possible outcomes without))/possible outcomes

So the probability of rolling a six in three rolls of dice:
((216)-(125))/216=91/216

Trying to apply this principle to this game.
Best response
Are the balls in order by some sort of system?

If not, it's a bell curve distribution. For instance, here's the chance for the 3 balls to return a 16:
http://www.wolframalpha.com/input/?i=3d10+chance+for+a+16

Just take that chance and multiply it by the number of games you want to run (in your case 22,000 per day).

If you're not looking for a specific number, you're going to have to do some stats:

EV: 16.5
SD: 4.975
Variance: 24.75

http://www.wolframalpha.com/input/?i=bell+curve

You want the Probability Density Function.

or in this case:

e^(-(x-16.5)^2/(2*24.75^2))/(sqrt(2pi*4.975)

Where x is the number you're looking for. Multiply the result by the number of games you want to run and you've got it.

I dunno if dm has a constant for e so you can use this

var/e = 2.7182818285...

if it doesn't. I think this will get you there. It's been a while since I took stats.

And if you're looking for a game where the rolls aren't summed, I'll leave that to someone else.

Michael3131 wrote:
P.S. I am predicting the probability of a single outcome of a 1000 possible outcome event that has already happened 11000 times. This is just one part of the equation.

You mean you roll number 1 to 1000, and want to know probability of getting 1000 if you roll 11,000 times? You could find different (easier) answer. What's the chance you WON'T roll it? (999/1000) ^ 11000. Then chance to roll will be 1 - (999/1000) ^ 11000 = 0.99998339 (according to Wolfram Alpha). But this is still huge exponent. Using probability formulas are easier here.
In response to Zaoshi
Zaoshi wrote:
Michael3131 wrote:
P.S. I am predicting the probability of a single outcome of a 1000 possible outcome event that has already happened 11000 times. This is just one part of the equation.

You mean you roll number 1 to 1000, and want to know probability of getting 1000 if you roll 11,000 times? You could find different (easier) answer. What's the chance you WON'T roll it? (999/1000) ^ 11000. Then chance to roll will be 1 - (999/1000) ^ 11000 = 0.99998339 (according to Wolfram Alpha). But this is still huge exponent. Using probability formulas are easier here.

That works a lot easier! Only issue I'm still running into is I already know how many times it's come up within the 11,000 iterations. For example, 333 has come up let's say, 22 times. So I need to take that out of my percentage chance. Any ideas?
Well, if your chance to roll is 99.99%, you might as well just roll 1:10000 and if they land on 1, you can assume they didn't roll their target number.

Edit: Michael, that's irrelevant to the formula. That you have already rolled the target does not change how likely you are to roll the target again.

And if you already know how many times its come up, what are you using the formula for? You're not being clear.
I apologize. I'm trying to predict which of the 1,000 possible numbers, 000 through 999 will come up next. I was using past data with the probability formula as so:
11,000 times already
333 has come out 22 times

How likely is 333 to come out 23 times in 11,001 rolls? The idea was to use past data to figure out how likely each roll would be due to it's based data.
var/list/numbers[1000] // array to hold how many times each number came out
numbers[500] = 200 // number 500 came out 200 times
numbers[1000] = 4 // number 1000 came out 4 times

// find how many rolls we're done in total
var/totalNumber = 0
for(var/i = 1; i <= 1000; i++)
totalNumber += numbers[i]

for(var/i = 1; i <= 1000; i++)
world << "Chance for [i] to be next is [numbers[i] / totalNumber]"


If you are trying to predict which number will be next.

Extra info:
Do you have huge amount of data and try to predict next value (similar to stock market prices)? In that case Neural Network is better solution, it tends to give much better predictions in very near future with good training. Though you'd have to use something more powerful than BYOND.
I do have a ton. I have 11,000 past results to pull future results from. I tried doing a method earlier to what you're saying, but this method would mean that a number that came up statistically way too much is more likely to come up. (Which could be true due to faulty randomizers). I'll look up Neural Network.
In response to Michael3131
Michael3131 wrote:
I tried doing a method earlier to what you're saying, but this method would mean that a number that came up statistically way too much is more likely to come up. (Which could be true due to faulty randomizers)

1. If it's random (coin toss, dice roll, etc) then there's nothing to calculate, everything has equal chance.

2. If it's RNG, then faulty function will cause some values to appear more often, with a lot data you can pretty much tell which value appears the most often, but it will never give you good answer.

3. Neural Network might predict next value, however it depends a lot on data, just like (2) does.
1. It has equal chance each time but over an extended period of time it will approach equal distribution. I was hedging on that fact.

2 & 3. I agree. I think I will just see how % correct the top 20 outcomes and bottom 20 outcomes are. It's a bit less technical, and I can use what I have to keep track of the values and how often they've been used.