Go Down

Topic: Factorial problem (Read 706 times) previous topic - next topic

RobertEagle

Jan 26, 2013, 03:00 pm Last Edit: Jan 26, 2013, 03:03 pm by RobertEagle Reason: 1
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

PaulS

What does this have to do with the Arduino? Go find a homework hotline to ask.

PeterH


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.
I only provide help via the forum - please do not contact me for private consultancy.

JimboZA


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.
Arduino ethernet server here.... http://jimboza.gotdns.com:8085/

No PMs for help please

RobertEagle

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.


PaulS

Quote
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.

JimboZA

Quote
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?
Arduino ethernet server here.... http://jimboza.gotdns.com:8085/

No PMs for help please

JimboZA

Quote
.... permutations. Explain what that has to do with factorial


Well there's the old n! / (n-r)! stuff, maybe that's what he means.

But to me the question is, Why use an Arduino for that computation?
Arduino ethernet server here.... http://jimboza.gotdns.com:8085/

No PMs for help please

PeterH


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.
I only provide help via the forum - please do not contact me for private consultancy.

RobertEagle

#9
Jan 26, 2013, 06:01 pm Last Edit: Jan 26, 2013, 06:04 pm by RobertEagle Reason: 1
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

JosAH

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

Go Up