r.stiltskin's Profile
Reputation: 1833
Grandmaster
 Group:
 Mentors
 Active Posts:
 4,956 (1.49 per day)
 Joined:
 27December 05
 Profile Views:
 39,489
 Last Active:
 Apr 29 2013 05:42 AM
 Currently:
 Offline
Previous Fields
 Country:
 US
 OS Preference:
 Linux
 Favorite Browser:
 FireFox
 Favorite Processor:
 Who Cares
 Favorite Gaming Platform:
 Who Cares
 Your Car:
 Who Cares
 Dream Kudos:
 100
 Expert In:
 Java and C++
Latest Visitors

macosxnerd101
10 Jan 2015  00:49 
sierranm
17 May 2014  21:38 
tarmizi_adam2005
18 Mar 2014  18:51 
jimblumberg
08 Mar 2014  11:41 
salazar
13 Sep 2013  20:25
Posts I've Made

In Topic: What is the probability of (X=6)?
Posted 16 Apr 2013
louisdjKSU, on 16 April 2013  09:18 PM, said:
... So how can we put a number on the possible outcomes? It's infinity, isn't it??
Thus P = 720/ infinity =0.
I wouldn't interpret it that way. Consider strings of length 7. There aren't only 720 "successful" strings of 7 characters, because the 7th character can be any of 4 possibilities. So there are 720*4 successful strings of length 7. And 720*4*4 successful strings of length 8. And so on. So if you want to consider strings of infinite length, there will be an infinite number of successes. But all of those trailing "4s" will appear in both the numerator and the denominator and cancel each other out.
Looking at it another way, suppose we were dealing with flips of a fair coin and I asked for the probability that the first heads appears on the second flip. Of course it is possible (unlikely, but possible) that tails comes up 1000 times before the first heads. Or 1000000 times. Or 1000000000 times. So would you say that therefore the probability of the first heads appearing on the second flip is 0?
I'd say that the universe of possible outcomes is HH HT TH TT, and the only "success" is TH, so the probability is 1/4. Or, it is the probability that heads doesn't come up on the first flip (1/2) times the probability that heads does come up on the second (also 1/2); therefore 1/2 * 1/2 = 1/4.
If we do 3 flips, the universe is HHH HHT HTH HTT THH THT TTH TTT and the successes are THH THT. Probability 2/8; i.e., still 1/4. And the same will hold for 4 flips, etc.
So for the OP's problem, I'd still say that the denominator is the number of possible strings of length 6 (of the alphabet ABCDE) in which there are no adjacent duplicates. And you can calculate the probability as the product of the probability that we don't find 1 of each character in a string of length 5 times the probability that we do find (at least) 1 of each character in a string of length 6. 
In Topic: Storing arithmetic operations in an array
Posted 15 Apr 2013
You should read about stringstream. You can write the result of your arithmetic to a stringstream the same way you would write it to cout, using the << operator. Then you can use the stringstream's str() member to output that result as a C++ string. And then you can access the individual digits of the string using the [] operator, just as you would in an array. 
In Topic: having trouble.
Posted 10 Apr 2013
makeitloud, on 10 April 2013  10:31 AM, said:
... call is not being initialized.
Do you know what that means?
It means that your program is trying to use the value of call, but that you never assigned any value to call.
It also means that either you didn't pay attention to (or didn't understand) the last comment in my previous post. Look at it again. 
In Topic: having trouble.
Posted 10 Apr 2013
In the 'else' block on lines 6279 (and incidentally, I suggest placing that code in braces {} ) you already know that choice == 'y'. The program won't get into that block otherwise. So there's no point having any 'if' statements containing choice == 'y' or choice != 'y' in their conditional expressions.
And if you're in the 'else' block on lines 6879, it has already been established that coins > 0, so there's no point having coins <= 0 as a condition there. In fact, neither of the 'if' conditions in this block can ever be satisfied because we already know that choice == 'y' and coins > 0.
Furthermore, you input a value for choice2, but where do you ever use it?
Take a closer look at line 36 too. 
In Topic: What is the probability of (X=6)?
Posted 8 Apr 2013
deprosun, on 08 April 2013  06:57 PM, said:
That seems correct for P(X=5), but P(X=6) is much more complex.There are five songs, lets say {A,B,C,D,E}.
No song is played twice in a row. For example, ABACAE is valid; while ABBACE is not.
Let X be the number of songs played until every song has played.
What is the value of P(X=6)?
Lets say, if we are to find P(X=5).
Wouldn't we do5*4*3*2*1/5*4*4*4*4
?
macosxnerd101, on 08 April 2013  07:29 PM, said:
So you have 5! ways of permuting AE. Then you choose a song to stick at the end, so C(4, 1) = 4. The total number of ways to arrange five elements in a string of length 6 is 5^6. So: P(X = 6) = 5! * 4/5^6
Not correct. Your numerator is the number of ways to play each of 5 songs once in the first 5 plays, and then play one more song without duplicating the 5th one. And your denominator is the number of ways to play a string of 6 plays (out of 5 songs) with no restrictions as to order. So it seems to be the probability that each song is played once in the first 5 selections, and that the 6th song doesn't duplicate the 5th, when songs are chosen completely randomly (not according to the stated rule).
Your problem is to find the number of 5strings, each consisting of 4 letters out of a 5letter alphabet, in which duplicates are not in adjacent positions, and then multiply that by the number of ways you can select a set of 4 out of 5 letters. You can visualize it this way:
x _ x _ _
x _ _ x _
x _ _ _ x
_ x _ x _
_ x _ _ x
_ _ x _ x
The x's mark the locations where the duplicated letters are placed. The underscores mark the locations where the remaining 3 out of each set of 4 letters can be placed (and permuted).
So you're going to choose 4 out of 5 letters to place in those first 5 positions, and choose 1 out of 4 to be duplicated, and then permute the remaining 3. And multiply by the number of ways to choose 1 out of 4, and by the number of ways to chooose 4 out of 5.
And finally divide the resulting number of events by the total number of possible strings that obey the "no consecutive duplicates" rule (NOT all possible strings of 6) to find the probability.
My Information
 Member Title:
 D.I.C Lover
 Age:
 Age Unknown
 Birthday:
 Birthday Unknown
 Gender:
 Years Programming:
 10
 Programming Languages:
 c, c++, java, lisp
Contact Information
 Email:
 Click here to email me
 Website URL:
 http://

Comments
aresh
09 Jul 2012  01:39aaron1178
13 May 2012  06:45Btu
24 Mar 2012  00:51B
ssharma286
21 Dec 2011  16:16ishkabible
04 Dec 2011  19:25ishkabible
04 May 2011  06:00ishkabible
21 Mar 2011  19:24modi123_1
15 Mar 2011  12:36goldfish
26 Feb 2011  07:46James1981
25 Feb 2011  10:35bedmond
16 Oct 2010  19:31greenska_89
17 Jun 2010  14:55really appreciate it..
thank you very much
wmugume2000
06 May 2010  15:25