Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Probability...Simple problem, need help getting started

Subject: Probability...Simple problem, need help getting started

From: Don

Date: 1 Dec, 2010 18:43:05

Message: 1 of 8

Ok so my problem is, assume that the barbershop is open from 9-5, or for 8 hours a day. Person A and Person B each stay 30 min during visit, never longer, never shorter.
What is the probability that they run into one another?

Sample space: is 9-5 (The time the shop is open.) But should be denoted in matlab as 0-8.

The equation that satisfies the condition is -.5 < | x-y | < .5, which breaks down into two equations y < x +.5 and y > x - .5

Two graphs, and and the strip in the middle is the probability that they run into one another. To find the probability we must find the area of the strip in the middle, which we can do by simple math. (.5)(base)(height) which is this example is (.5)(7.5)(7.5) = 28.125 * 2 = 56.25 (Times it by two because of the two triangles made by the equations)


64 (total area of the 8x8 graph) - 56.25 = 7.75/64 = 12 percent probability.

The math is easy for me to understand but programming throws me off. If someone could give me a push in the right direction i'd appreciate it.

Thanks :)

Subject: Probability...Simple problem, need help getting started

From: Don

Date: 1 Dec, 2010 18:58:05

Message: 2 of 8

x=0:8; % Using the colon operator to create a vector of x values ranging from 0 to 8
y= x-.5; %Equation for Person A
y2= x+.5; %Equation for Person B
plot(x,y,x,y2);

xlabel('Hours of the Barbershop')
ylabel('Hours of the Barbershop')
title('Plot of the Barbershop probability problem')
legend('Person A','Person B')


This is what I have so far, is there anyway to shade the middle to show the probability of it happening? Still need help applying the math part...

Subject: Probability...Simple problem, need help getting started

From: Don

Date: 1 Dec, 2010 19:14:07

Message: 3 of 8

found out about the built in function of the probability plot and wondering how to plot two functions...?


probplot(y) works, but probplot(y,y2) doesn't...

Subject: Probability...Simple problem, need help getting started

From: Don

Date: 1 Dec, 2010 19:21:04

Message: 4 of 8

ok so I have found out the use of the probplot function but don't understand how to use both functions, i can only figure out how to use one function on one plane, not both functions on a single plane

Anyone have any insight?

Subject: Probability...Simple problem, need help getting started

From: Walter Roberson

Date: 1 Dec, 2010 19:22:10

Message: 5 of 8

On 01/12/10 1:21 PM, Don wrote:
> ok so I have found out the use of the probplot function but don't
> understand how to use both functions, i can only figure out how to use
> one function on one plane, not both functions on a single plane
>
> Anyone have any insight?

Have you tried using "hold on" after the first plot?

Subject: Probability...Simple problem, need help getting started

From: Don

Date: 1 Dec, 2010 19:30:22

Message: 6 of 8

Walter Roberson <roberson@hushmail.com> wrote in message <DfxJo.13146$Bs7.5774@newsfe07.iad>...
> On 01/12/10 1:21 PM, Don wrote:
> > ok so I have found out the use of the probplot function but don't
> > understand how to use both functions, i can only figure out how to use
> > one function on one plane, not both functions on a single plane
> >
> > Anyone have any insight?
>
> Have you tried using "hold on" after the first plot?

Just tried...doesn't do anything >.<

Subject: Probability...Simple problem, need help getting started

From: Sean de

Date: 1 Dec, 2010 19:45:08

Message: 7 of 8

"Don " <don.jackson@coker.edu> wrote in message <id67oe$lun$1@fred.mathworks.com>...
> Walter Roberson <roberson@hushmail.com> wrote in message <DfxJo.13146$Bs7.5774@newsfe07.iad>...
> > On 01/12/10 1:21 PM, Don wrote:
> > > ok so I have found out the use of the probplot function but don't
> > > understand how to use both functions, i can only figure out how to use
> > > one function on one plane, not both functions on a single plane
> > >
> > > Anyone have any insight?
> >
> > Have you tried using "hold on" after the first plot?
>
> Just tried...doesn't do anything >.<

How about:
%%%
hold on
fill([x fliplr(x)],[y fliplr(y2)],'c')

Subject: Probability...Simple problem, need help getting started

From: Roger Stafford

Date: 1 Dec, 2010 20:04:06

Message: 8 of 8

"Don " <don.jackson@coker.edu> wrote in message <id64vp$hba$1@fred.mathworks.com>...
> Ok so my problem is, assume that the barbershop is open from 9-5, or for 8 hours a day. Person A and Person B each stay 30 min during visit, never longer, never shorter.
> What is the probability that they run into one another?
> Sample space: is 9-5 (The time the shop is open.) But should be denoted in matlab as 0-8.
> The equation that satisfies the condition is -.5 < | x-y | < .5, which breaks down into two equations y < x +.5 and y > x - .5
> Two graphs, and and the strip in the middle is the probability that they run into one another. To find the probability we must find the area of the strip in the middle, which we can do by simple math. (.5)(base)(height) which is this example is (.5)(7.5)(7.5) = 28.125 * 2 = 56.25 (Times it by two because of the two triangles made by the equations)
> 64 (total area of the 8x8 graph) - 56.25 = 7.75/64 = 12 percent probability.
> The math is easy for me to understand but programming throws me off. If someone could give me a push in the right direction i'd appreciate it.
> Thanks :)
- - - - - - - - -
  I don't agree with your sample space assumptions, Don. You have stated that each person always stays 30 minutes, never more or less. This restricts the placement of a 30-minute time interval to a span of 7.5 hours, so your total sample space for two people is 7.5 by 7.5. Your outside triangles are correspondingly smaller at 7 by 7. I get twelve and eight/ninths percent probability for your problem.

  Of course this assumes that each person will certainly visit just once during the day at uniformly distributed times and that their times are mutually independent (all questionable assumptions in real life.)

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us