Jump to content

Can someone help me with an algorithm?

GirvanaWantsBinnieBalls

I want to make an algorithm for personal use.

The algorithm will be based on chance giving results based on what i give it.

 

For example : Choise A has 30% chance to hit , Choise B has 50% Chance to hit , And choice C has 20% chance to hit.

 

Let's say that i  give the algorithm A , then it will be 0.3x0.3 ( 0.30x0.30 ) chance to hit and  the rest B and C chances will grow accordingly .

 

The algorithm will then choose one of the 3 choises and give it to me as a result .

 

Is that possible ? If yes , can you help me? Or atleast find me an article about it ? 

 

Link to comment
Share on other sites

Link to post
Share on other sites

What language are you using?

 

Most will have a random function that spits out a random number between a certain range. 

So if number is < .3 * range you've got your 30% condition

else if number is < (.3 + .5) * range, that's your 50% condition.

else it's the 20%

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...

Fashioning an algorithm to determine if it's hit or miss is easy. But I'm a bit confused about  what you meant by "and  the rest B and C chances will grow accordingly". Given that there 4 possible outcomes for three actors/players: 

 

  • Only one will score a hit. 
  • Two will score a hit, 1 will miss.
  • All three will score a hit.
  • All three will miss.

The following questions comes to mind:

  • How will the chances of other players grow? What rules will govern this change?
  • Is only one actor expected to score a hit? 
  • Or, am I misunderstanding the requirement?

 

Link to comment
Share on other sites

Link to post
Share on other sites

Could you explain explicitly what you want it to do? I don't understand what you described, as A, B, and C would be independent events.

If you specify that a given event happens, it doesn't affect the probabilities in the next 'roll'. If, however, you specify a sequence of events, then you can compute the probability by taking the product of the probabilities of the individual events -So the probability of A in the second roll given that the first roll was A is still .3, but the probability of rolling A twice is .09.

"Do as I say, not as I do."

-Because you actually care if it makes sense.

Link to comment
Share on other sites

Link to post
Share on other sites

On 12/27/2017 at 8:32 AM, GirvanaWantsBinnieBalls said:

Let's say that i  give the algorithm A , then it will be 0.3x0.3 ( 0.30x0.30 ) chance to hit and  the rest B and C chances will grow accordingly .

 

Why would you want to even do that? That gives A a 90% chance by force instead of 30%, it defeats the purpose of any algorithm.

 

You also want a algorithm to increase odds for the other 2 options however in order for anyone to create such a algo you would need to give the rates of loss and acceleration.

One could create a algo w/o the number of decrease/increase.

 

Basically does A lose 5% or 10% when it gets chosen, and does B get a increase substantial to its number over C. What i mean by that, say A loses 5% and B takes majority due to it being a 50% odd it would gain 71% of the 5%.

So the odds would be now:

A: 25%

B: 53.55%

C: 21.45%

 

Two other things you need to look into are:

How accurate do you want the % to be do you want 1% or do you want 0.0001% accuracy?

How is the data going to be stored? It can be stored within the script if it is ran nonstop but would need a offsite (not in the script) storage of the data (the % of ABC) if it is only ran when called upon, it could store the data within itself if not ran all the time but could make it slow depending on the accuracy and execution of getting said accuracy.

Link to comment
Share on other sites

Link to post
Share on other sites

21 hours ago, Egg-Roll said:

Why would you want to even do that? That gives A a 90% chance by force instead of 30%, it defeats the purpose of any algorithm.

 

You also want a algorithm to increase odds for the other 2 options however in order for anyone to create such a algo you would need to give the rates of loss and acceleration.

One could create a algo w/o the number of decrease/increase.

 

Basically does A lose 5% or 10% when it gets chosen, and does B get a increase substantial to its number over C. What i mean by that, say A loses 5% and B takes majority due to it being a 50% odd it would gain 71% of the 5%.

So the odds would be now:

A: 25%

B: 53.55%

C: 21.45%

 

Two other things you need to look into are:

How accurate do you want the % to be do you want 1% or do you want 0.0001% accuracy?

How is the data going to be stored? It can be stored within the script if it is ran nonstop but would need a offsite (not in the script) storage of the data (the % of ABC) if it is only ran when called upon, it could store the data within itself if not ran all the time but could make it slow depending on the accuracy and execution of getting said accuracy.

i found a site that can do a similar thing... But thnx anyways!

Link to comment
Share on other sites

Link to post
Share on other sites

5 hours ago, GirvanaWantsBinnieBalls said:

I found a site that can do a similar thing... But thanks anyways!

I'm still curious what exactly you wanted. Is it a random sample without replacement?

"Do as I say, not as I do."

-Because you actually care if it makes sense.

Link to comment
Share on other sites

Link to post
Share on other sites

32 minutes ago, Dash Lambda said:

I'm still curious what exactly you wanted. Is it a random sample without replacement?

Basically , imagine you have a machine that has 3 choices , and every time it only gives u one result based on their propability

 

Say A has 30% chance to hit , B has 50% and C has 20%

 

The ''machine'' will choose one of these choices randomly based on their chance... in big numbers say after a 1000 ''rolls''

 

A should have hit about 300 times , B should have hit about 500 times ,  and C should have hit about 200 times

 

Now say that B was chosen from the machine . Next roll's chances are 0.5x0.5 for B which is 25% chance now , 

A has 30% chance + 15% chance = 45% chance , and C has 20% + 10% = 30% chance to hit.

And based on these results the ''machine'' picks up a letter (result ) and the algorithm goes on  and on and on...

Link to comment
Share on other sites

Link to post
Share on other sites

38 minutes ago, Dash Lambda said:

I'm still curious what exactly you wanted. Is it a random sample without replacement?

but i thought about it , and it is incorrect... the machine should still have the same chances no matter how many times B  or C hit...

The chance of hitting B 2 times is 0.5 x 0.5 , but the machine still remains on its original standpoint... i was wrong and confused some people here and i apologise!

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, GirvanaWantsBinnieBalls said:

but i thought about it , and it is incorrect... the machine should still have the same chances no matter how many times B  or C hit...

The chance of hitting B 2 times is 0.5 x 0.5 , but the machine still remains on its original standpoint... i was wrong and confused some people here and i apologise!

In that case it's real easy, you need a random number generator 1-10 will work because you have a 30/50/20% chances so they can go down by 10 to become 3/5/2.

To switch things up one could give number 2,4,6,8,10 for B, 1,5,9 for A and 3,7 for C. This makes it so the numbers if always hitting low numbers don't always hit the same letter, after all you have a 50/50 chance of getting numbers below 5.

 

Out of a simulation of 1000 times you should get the rough % required.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×