Hi,
This is my first post so you can tell I'm a noob.
I have an idea of a project which takes a number read from a file and then outputs.

However this is where I'm stuck, I want this number to increase the probability of outputting as it gets larger.
Although I'll only have one output so it is either on or off.

The number won't be larger than 100.
My idea was to divide the number by 10 and round up or down. Then generate a number between 1 and 10 and compare it to the divided number.

This is kinda hard to explain so an example.
The number is 34
Divided by 10 = 3.4 (rounded down to 3)
Then it will generate a number and if it is greater than 3 it will be off and if its less than or equal to, it would activate the output.

Is this feasible? And is there any better way to do it?
Thanks,

Robin2:
Why bother dividing by 10 when you could just compare 34 to 30. Using integers is a lot faster on an Arduino.

I think you need to give us a few examples that illustrate how the size of the number affects things.

...R

That's a great point, I was doing that just to make it simpler (Was constructing the idea late night/early morning) but maybe its not and I might be able to get a more precise chance that way.

An example of how the size affects it would be, if the number was 80, there is an 80% to activate the output and only 20% not to. But if it was 30, there would be a 30% chance for it to activate and 70% not to.

Gregulimy:
An example of how the size affects it would be, if the number was 80, there is an 80% to activate the output and only 20% not to. But if it was 30, there would be a 30% chance for it to activate and 70% not to.

Maybe my brain is asleep tonight but I can’t relate that to your earlier example

The number is 34
Divided by 10 = 3.4 (rounded down to 3)
Then it will generate a number and if it is greater than 3 it will be off and if its less than or equal to, it would activate the output.

which does not seem to have any probability attached to it. If it is greater than 3 it will be off

Gregulimy:
The number is 34
Divided by 10 = 3.4 (rounded down to 3)
Then it will generate a number and if it is greater than 3 it will be off and if its less than or equal to, it would activate the output.

To place probability on it, the generated number has a 70% chance of being greater than 3 and a 30% chance of being less than or equal to 3 (So in theory a 70% chance of being of being off, and 30% of being on)

Sorry for the confusion (Starting to confuse myself again)

x = random(2); // The number is 0 or 1. There is a 50% chance the number is zero.
x = random(3); // The number will be between 0 and 2. It will equal zero 1 out of 3 times.
x = random(10); // There's a 10% chance the number will be zero.

I've used that method for 50/50 quite a bit, and in my applications I've used one-out-of-3 quite a bit too.

But, that won't work if you are reading numbers from a file...

Another method that I haven't used is to generate a random number between 1 and 100.

Once you have a random number between 1 and 100, there is a 50% chance it's 50 or less. There's a 1% chance it's one, and a 99% chance it's less than 100, etc.

That method will only work (with the expected probabilities) if the numbers read from your file are truly random.

And... Probability and randomness means there is uncertainty... If you flip a coin 100 times, you expect to get heads 50 times. But, there's a good chance of getting a different result. If you run that 100-flip experiment many times the average should be about 50 heads. You can flip a coin 5 times and get heads 5 times in a row... It's just unlikely.

DVDdoug:
Another method that I haven't used is to generate a random number between 1 and 100.

Once you have a random number between 1 and 100, there is a 50% chance it's 50 or less. There's a 1% chance it's one, and a 99% chance it's less than 100, etc.

That method will only work (with the expected probabilities) if the numbers read from your file are truly random.

Yeah that makes sense.
The numbers will be under 100 and to two decimal places most likely, but then rounded

Gregulimy:
To place probability on it, the generated number has a 70% chance of being greater than 3 and a 30% chance of being less than or equal to 3 (So in theory a 70% chance of being of being off, and 30% of being on)

I wonder if what you are trying to say is that you want to generate a random number and then compare it to see if it is higher or lower than a control value?