Results 1 to 6 of 6

Thread: Probabilities in matlab

  1. #1
    Join Date
    May 2008
    Posts
    222

    Probabilities in matlab

    Hello,
    As part of a project I have a problem, It performs a series of throws of a dice and it stops when it gets an ace. Then there are the number of shots needed. I try to do a simulation in matlab and I can not make a program that would allow me to get results (if there was a loop while I'd finish but it is not). In short which are the probabilities in metlab to use for my project. If you have an idea that would help me. Thank you in advance.
    Last edited by Brunoz; 05-01-2010 at 11:06 AM.

  2. #2
    Join Date
    May 2008
    Posts
    222

    Re: Probabilities in matlab

    Hello
    Well I can not get my while loop. The probability of getting an ace during a run is 0.167.
    So I make 100 simulations:
    Code:
    a = 1
    Choose u between 0 and 1
    Code:
    As u > 0.167
    fair: a = 1 and u choose between 0 and 1.
    This will gives me a.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Probabilities in matlab

    Hello
    I'd rather run a simulation of the die-
    Code:
    in = rd (5 * rand (1)) + 1;
    start = 1;
    while (from ~ = 6)
        in = rd (5 * rand (1)) + 1;
        start = start + 1;
    end
    2 comments:
    - don 't forget to initialize the pseudo random generator, "help rand" should tell you how.
    - law distribution that you want, you can use randp, randn, randg

  4. #4
    Join Date
    May 2008
    Posts
    222

    Re: Probabilities in matlab

    Hello
    Thank you for the code. But before your answer I tried to search a bit by the following code:
    Code:
    for i = 1:100;
    a (1, i) = 1;
    u (1, i) = rand;
    while u (1, i)> 0.1667
    a (1, i) = a (1, i) +1;
    u (1, i) = rand;
    end
    end
    stem (a), grid
    mean (a),% average
    Matlab gives me as error message: "Missing operator, comma, or semi-colon."
    I do not understand what is wrong. Thank you in advance.

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Probabilities in matlab

    Hello everyone,
    I have a big foot to ask in relation to a problem that I can not solve.
    Would there be someone who could help me build a mathematical model using two data vectors using scilab. Thank you. Help please.

  6. #6
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Probabilities in matlab

    Hello
    I advise you describe what you want to do what you have done and what you can not make because
    construct a mathematical model using two data vectors
    This does not mean much.
    In me your script work, but it's true that I use OCTAVE which may be different behavior of MATLAB. Perhaps the ";" on line "for" problem? Or perhaps that MATLAB requires an argument "rand"?

Similar Threads

  1. Are these probabilities possible in Zynga poker?
    By Pierson in forum Video Games
    Replies: 5
    Last Post: 05-03-2011, 05:52 AM
  2. How to begin with MATLAB?
    By Jacques25 in forum Software Development
    Replies: 3
    Last Post: 18-01-2011, 07:57 AM
  3. How to convert MATLAB to C?
    By The Recruiter in forum Software Development
    Replies: 6
    Last Post: 17-04-2010, 06:15 AM
  4. Matlab 7.9 crashes under Windows 7
    By Chandranath in forum Windows Software
    Replies: 5
    Last Post: 13-01-2010, 03:58 AM
  5. Calling winrar from matlab
    By go raiden in forum Software Development
    Replies: 5
    Last Post: 02-09-2008, 08:00 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,583,412.36583 seconds with 17 queries