r.stiltskin's Profile User Rating: ****-

Reputation: 1833 Grandmaster
Group:
Mentors
Active Posts:
4,956 (1.63 per day)
Joined:
27-December 05
Profile Views:
36,252
Last Active:
User is offline 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

Icon   r.stiltskin has not set their status

Posts I've Made

  1. In Topic: What is the probability of (X=6)?

    Posted 16 Apr 2013

    View PostlouisdjKSU, 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.
  2. 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.
  3. In Topic: having trouble.

    Posted 10 Apr 2013

    View Postmakeitloud, 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.
  4. In Topic: having trouble.

    Posted 10 Apr 2013

    In the 'else' block on lines 62-79 (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 68-79, 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.
  5. In Topic: What is the probability of (X=6)?

    Posted 8 Apr 2013

    View Postdeprosun, on 08 April 2013 - 06:57 PM, said:

    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 do
    5*4*3*2*1/5*4*4*4*4
    
    ?
    That seems correct for P(X=5), but P(X=6) is much more complex.


    View Postmacosxnerd101, on 08 April 2013 - 07:29 PM, said:

    So you have 5! ways of permuting A-E. 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 5-strings, each consisting of 4 letters out of a 5-letter 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

E-mail:
Click here to e-mail me
Website URL:
Website URL  http://

Comments

Page 1 of 1
  1. Photo

    aresh Icon

    09 Jul 2012 - 01:39
    You don't seem to be online now-a-days...
  2. Photo

    aaron1178 Icon

    13 May 2012 - 06:45
    Your my C++ idol :))
  3. Photo

    Btu Icon

    24 Mar 2012 - 00:51
    I just wanted to personally thank you for taking so much time to explain things on my threads. You have been a really big help.
    -B
  4. Photo

    ssharma286 Icon

    21 Dec 2011 - 16:16
    Thank you so MUCH! You are the most helpful person ever! THANKS A BUNCH finally got the binary tree working. I am impressed by how quickly you are able to spot such complex errors! Hopefully I can be as good a programmer as you one day :P
  5. Photo

    ishkabible Icon

    04 Dec 2011 - 19:25
    your back!!
  6. Photo

    ishkabible Icon

    04 May 2011 - 06:00
    lookin' good in purple :)
  7. Photo

    ishkabible Icon

    21 Mar 2011 - 19:24
    you need to be a forum leader
  8. Photo

    modi123_1 Icon

    15 Mar 2011 - 12:36
    400x80 is the preferred sig image size. 490x137 isn't quite it.
  9. Photo

    goldfish Icon

    26 Feb 2011 - 07:46
    Thank you so much for stopping me from going to wrong way. I'm going to work on it today and may bring my code back later when I have MORE problems.
  10. Photo

    James1981 Icon

    25 Feb 2011 - 10:35
    Thanks for your help with my posts! Sorry if I was unclear at times. I am pretty useless when it comes to computers but I am learning. Thanks again!
  11. Photo

    bedmond Icon

    16 Oct 2010 - 19:31
    thanks
  12. Photo

    greenska_89 Icon

    17 Jun 2010 - 14:55
    thanks for your posts at my question..
    really appreciate it..
    thank you very much
  13. Photo

    wmugume2000 Icon

    06 May 2010 - 15:25
    I am really so greatful for your assistance,all the unwavering efforts you put to my bidding similation programe.Am not yet done! but I appreciate all.
Page 1 of 1