Be the first to rate this file! 16 downloads (last 30 days) File Size: 2.23 KB File ID: #23478

Brain Teaser Solver

by Rodolphe Sitter

 

30 Mar 2009 (Updated 30 Mar 2009)

Code covered by the BSD License  

Brain Teaser Solver: Compute the expected time to get a given sequence of independent outcomes.

Download Now | Watch this File

File Information
Description

The function OutcomeSequence.m solve brain teasers such as:

1. You toss a coin, what is the expected number of tosses for you to get the sequence 'Tails-Heads-Tails' ?

2. You throw a dice, what is the expected number of throws for you to get the sequence '1, 2, 3, 2, 1' ?

3. You randomly hit your keyboard, what is the expected number of keys you have to hit to get the sequence 'ABRACADABRA' ?

4. You play one poker game everyday. Assume you are likely to win 1 out of 4 games you play. What is the expected number of days you have to play to win 3 times in a row ?

Function details:
OutcomeSequence(Sequence, N_Outcomes)

Inputs:
   - Sequence: sequence (row vector) of numbers representing the different possible outcomes. The occurrence times of those outcomes are assumed to be I.I.D. random variables, i.e. the outcomes occur independently of each other and are equally likely to happen.
   - N_Outcomes: number of different possible (independent) outcomes.

  Output:
   - Expected_Time: expected time to get the input sequence of outcomes. This time would correspond to a number of tosses of a coin, throws of a dice and so on depending on the problem considered.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
30 Mar 2009

more examples in comments

Tag Activity for this File
Tag Applied By Date/Time
sequence Rodolphe Sitter 30 Mar 2009 15:12:34
outcome Rodolphe Sitter 30 Mar 2009 15:12:34
dice Rodolphe Sitter 30 Mar 2009 15:12:34
coin Rodolphe Sitter 30 Mar 2009 15:12:34
random time Rodolphe Sitter 30 Mar 2009 15:12:34
iid Rodolphe Sitter 30 Mar 2009 15:12:34
game Rodolphe Sitter 30 Mar 2009 15:12:34
brain teaser Rodolphe Sitter 30 Mar 2009 15:12:34
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com