Offline
Full Member
Karma: 0
Posts: 181


« on: January 26, 2013, 09:00:52 am » 
Hi,
I have here a situation. The problem I was given is a number. It's about factorial. My number is in my case 3.
So practically these are the combinations: 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1
The problem is to find out which is the probability of a specific number to be in front of another specific number? Like 3 in front of 1? Is there any math function which describes this probability regarding the factorial number? I'm trying to do this without making a permutation function. As I think, the permutation function would be much more complex and cpu intensive than a simple math function, therefore much more efficient.
Thank you in advance, RobertEagle


« Last Edit: January 26, 2013, 09:03:20 am by RobertEagle »

Logged





Seattle, WA USA
Offline
Brattain Member
Karma: 601
Posts: 48556
Seattle, WA USA


« Reply #1 on: January 26, 2013, 09:30:02 am » 
What does this have to do with the Arduino? Go find a homework hotline to ask.



Logged





UK
Offline
Shannon Member
Karma: 223
Posts: 12577



« Reply #2 on: January 26, 2013, 10:01:09 am » 
The problem is to find out which is the probability of a specific number to be in front of another specific number? Like 3 in front of 1? Is there any math function which describes this probability regarding the factorial number?
I don't see how that problem relates to factorials, or Arduino. In any case, the whole point of an academic assignment is that you solve the problem.



Logged

I only provide help via the forum  please do not contact me for private consultancy.




Johannesburg. UTC+2
Offline
Faraday Member
Karma: 82
Posts: 3864


« Reply #3 on: January 26, 2013, 10:15:13 am » 
What does this have to do with the Arduino?
Well I suppose he could use the Arduino as his calculation engine after writing a sketch, and blink LEDs to signify the answer. @OP... if that is the actual problem, you can solve it by inspection..... Count how many times n is in front of m. There are 6 combinations as you point out.... so the chance of n in front on m is easy to see.



Logged

The Elders of the Internet know who I am.....




Offline
Full Member
Karma: 0
Posts: 181


« Reply #4 on: January 26, 2013, 10:53:08 am » 
Yes. But thinking that this process actually takes a lot of cycles (the permutation and then counting), I thought there's a simpler way of getting this value. By having a mathematics function which describes this percentage. You see, the Arduino is not that powerful for what I want. After all, there's only 16Mhz.



Logged





Seattle, WA USA
Offline
Brattain Member
Karma: 601
Posts: 48556
Seattle, WA USA


« Reply #5 on: January 26, 2013, 11:01:18 am » 
You see, the Arduino is not that powerful for what I want. After all, there's only 16Mhz. How fast the processor is has little to do with your question. Does it matter if you get the answer in 3 microseconds vs. 3 milliseconds? Your question is about the order of values in a set of permutations. Explain what that has to do with factorial.



Logged





Johannesburg. UTC+2
Offline
Faraday Member
Karma: 82
Posts: 3864


« Reply #6 on: January 26, 2013, 11:01:58 am » 
the Arduino is not that powerful for what I want Maybe it is, maybe it isn't... But why would you do this kind of computation on a micro controller board in the first place? There are probably scores, maybe hundreds, of compilers in dozens of languages that you could download to your PC and run the program there. Or are there things you want to control based on your answers?



Logged

The Elders of the Internet know who I am.....




Johannesburg. UTC+2
Offline
Faraday Member
Karma: 82
Posts: 3864


« Reply #7 on: January 26, 2013, 11:06:17 am » 
.... permutations. Explain what that has to do with factorial Well there's the old n! / (nr)! stuff, maybe that's what he means. But to me the question is, Why use an Arduino for that computation?



Logged

The Elders of the Internet know who I am.....




UK
Offline
Shannon Member
Karma: 223
Posts: 12577



« Reply #8 on: January 26, 2013, 11:49:33 am » 
Your question is about the order of values in a set of permutations. Explain what that has to do with factorial.
Or programming. Or Arduino programming. It's a homework assignment. Asking people to do it for you is cheating. You don't need us to solve this problem for you. You don't need an Arduino, or any computer at all. You just need to sit down and think about the problem. Which was the whole point of the assignment in the first place.



Logged

I only provide help via the forum  please do not contact me for private consultancy.




Offline
Full Member
Karma: 0
Posts: 181


« Reply #9 on: January 26, 2013, 12:01:54 pm » 
It's a local community, and this is my task. I do things, calculations, and depending on the values I turn on some things.
I have found a flaw. No matter what input data is, the percentage will always be a constant. With this, I don't even have to calculate and do something. So going from 3 ms, to 3us, I go even further, right?
The idea when I opened a topic, was because of my curiosity. I knew how to solve the problem on the hard way, but I wanted to go further. Why all this instructions? And PaulS, when I see that a program runs at a certain frequency and it works fine, why not optimize it?
Thank you very much for your assistance, RobertEagle


« Last Edit: January 26, 2013, 12:04:01 pm by RobertEagle »

Logged





Netherlands
Offline
Full Member
Karma: 3
Posts: 109


« Reply #10 on: January 26, 2013, 12:38:17 pm » 
For a list of unique numbers in a random order, for a certain number to be to the left of another number, the probability is 50%: it either is or isn't to the left of the other number. No computer whatsoever is needed.
kind regards,
Jos



Logged





