What is the Probability of Knowing Multiple Programming Languages?

In summary, the conversation discusses the calculation of probabilities using Baye's theorem and Venn diagrams, as well as the use of combinations to determine sample spaces. The main topic is calculating the probability of choosing employees with certain programming skills from a company. The participants also discuss how to account for overlaps in skills and the importance of selecting without replacement when calculating probabilities.
  • #1
izelkay
115
3

Homework Statement


This looks like a very simple question but I just can't seem to wrap my brain around it:
ODiUefV.jpg


Homework Equations


Baye's theorem, etc.

The Attempt at a Solution


For part (a)
To calculate this probability I need to know the sample space of the programmers right? This is the main thing I'm having trouble with.

I was thinking I just need to add up how many know Java, C, and Assembly (30 + 25 + 16) for the sample space and divide that by the number of people that know Java.
The amount of people that know Java would be 30 (Java) + 15 (Java and C) + 6 (Java and Assembly) + 5 (Java and C and Assembly).

So would the probability be 56/107? I'm really not sure about it though because I feel like I'm double-counting somewhere
 
Physics news on Phys.org
  • #2
izelkay said:
add up how many know Java, C, and Assembly (30 + 25 + 16)
As you suspected, that's counting some people twice.
You have enough information to work out exactly how many do any given combination. Start with: how many can do J and C but not A? A Venn diagram might help. Don't assume all employees can program.
 
  • Like
Likes izelkay
  • #3
Hi, haruspex, thanks for replying.

Would a venn diagram look like this?:
A5LaZcj.png

because I don't know the number of programmers that only know exclusively one language?
 
  • #4
izelkay said:
Would a venn diagram look like this?:
A5LaZcj.png
Right idea but wrong numbers. According to your diagram, how many can program Java and C (whether or not they can handle Assembler)? How does that compare with what you are told?
 
  • #5
Ohhh I think I see now. According to my diagram, 20 can handle Java and C. So I essentially need to build the diagram from the inside out starting with the very middle
Is this correct?:
CC9FFvZ.png
 
  • #6
Also to find the total amount of programmers, would I do:

J + C - J∩C + A - C∩A - J∩A + J∩C∩A

If I add J and C I'd be double counting some of J so I subtract the intersection, and do the same for the other elements. And at the end I'd need to add the intersection of all 3 elements since it kept getting subtracted out.

So there would be 45.

Then the probability that a programmer knows Java is 30/45, or 2/3.

For (b) I'd use Bayes's formula:

P(C|J) = P(J∩C) / P(J) = (15/45) / (30/45) = 1/2

For (c) wouldn't this mean that the programmers make up 3/4 of the company? So the size of the company should be 60.
 
Last edited:
  • #7
izelkay said:
Also to find the total amount of programmers, would I do:

J + C - J∩C + A - C∩A - J∩A + J∩C∩A

If I add J and C I'd be double counting some of J so I subtract the intersection, and do the same for the other elements. And at the end I'd need to add the intersection of all 3 elements since it kept getting subtracted out.

So there would be 45.

Then the probability that a programmer knows Java is 30/45, or 2/3.

For (b) I'd use Bayes's formula:

P(C|J) = P(J∩C) / P(J) = (15/45) / (30/45) = 1/2

For (c) wouldn't this mean that the programmers make up 3/4 of the company? So the size of the company should be 60.
I agree with all of that.
 
  • Like
Likes izelkay
  • #8
I'm stuck on (d) now:

I believe the sample space for this one would be (16 choose 3) = 560 since there are 16 assembly programmers and we're forming a group of 3. Then would I divide the total number of employees, 60, by 560 to get 3/28?
 
Last edited:
  • #9
izelkay said:
I'm stuck on (d) now:

I believe the sample space for this one would be (16 choose 3) = 560 since there are 16 assembly programmers and we're forming a group of 3. Then would I divide the total number of employees, 60, by 560 to get 3/28?
No, you are only concerned with those who can program in Assembler. None of the others are relevant.
16 choose 3 is a good start - that's the number of possible sets of 3. Which of those sets of 3 need to be counted separately?
 
  • #10
haruspex said:
No, you are only concerned with those who can program in Assembler. None of the others are relevant.
16 choose 3 is a good start - that's the number of possible sets of 3. Which of those sets of 3 need to be counted separately?
It says at least 1 out of the 3, so would it be (3 choose 1) + (3 choose 2) + (3 choose 3)?
 
  • #11
d
izelkay said:
I'm stuck on (d) now:

I believe the sample space for this one would be (16 choose 3) = 560 since there are 16 assembly programmers and we're forming a group of 3. Then would I divide the total number of employees, 60, by 560 to get 3/28?

You have a population of N people (all the employees who know Assembly), with N1 of type I and N2 of type II. Here, N1 = number (of Assembly programmers) who know Java, and N2 = N - N1. You select three people at random from the N, and want to know the probability that at least one of the chosen is type I. The complement is that none of the three is of type I---that is, that all three are type II. Remember: you select without replacement, so once Person 1 has been picked, he/she is removed from the candidate list for subsequent choosing.

Your answer C(3,1)+C(3,2)+C(3,3) is definitely the wrong number to consider.
 
Last edited:
  • Like
Likes izelkay
  • #12
Ray Vickson said:
d

You have a population of N people (all the employees who know Assembly), with N1 of type I and N2 of type II. Here, N1 = number (of Assembly programmers) who know Java, and N2 = N - N1. You select three people at random from the N, and want to know the probability that at least one of the chosen is type I. The complement is that none of the three is of type I---that is, that all three are type II. Remember: you select without replacement, so once Person 1 has been picked, he/she is removed from the candidate list for subsequent choosing.

Your answer C(3,1)+C(3,2)+C(3,3) is definitely the wrong number to consider.
If I go with the complement route, that means, as you said, none of the selected can program in Java. Extracting information from my Venn Diagram, there are 10 people that can program in Assembly and not in Java. So, with a team of 3, would the probability that NONE of them know Java be (10 choose 3) / (16 choose 3) ?
 
  • #13
izelkay said:
Extracting information from my Venn Diagram, there are 10 people that can program in Assembly and not in Java. So, with a team of 3, would the probability that NONE of them know Java be (10 choose 3) / (16 choose 3) ?
Yes.
 
  • Like
Likes izelkay
  • #14
izelkay said:
If I go with the complement route, that means, as you said, none of the selected can program in Java. Extracting information from my Venn Diagram, there are 10 people that can program in Assembly and not in Java. So, with a team of 3, would the probability that NONE of them knows Java be (10 choose 3) / (16 choose 3) ?
You might find it instructive to solve the problem with your original approach as well to see where you went astray. Start with the simpler problem of determining the number of teams from the 16 who know assembly with 1 programmer who knows Java and 2 who don't. How would you calculate that?
 
  • Like
Likes izelkay
  • #15
vela said:
You might find it instructive to solve the problem with your original approach as well to see where you went astray. Start with the simpler problem of determining the number of teams from the 16 who know assembly with 1 programmer who knows Java and 2 who don't. How would you calculate that?
Yes thank you that's a good way to study.

At least 1 means I can either have all 3 know Java, just 2 know Java, or only 1 know Java.
Again, extracting information from my venn diagram, there are 6 people who know both Java and Assembly, and 10 people who know Assembly but not Java.

For 1 that knows Java: (6 choose 1)(10 choose 2)
For 2 that know Java: (6 choose 2)(10 choose 1)
For 3 that know Java: (6 choose 3)(10 choose 0)

So then the probability would be [(6 choose 1)(10 choose 2) + (6 choose 2)(10 choose 1) + (6 choose 3)(10 choose 0) / (16 choose 3)]
 
  • Like
Likes vela and Ray Vickson
  • #16
izelkay said:
Yes thank you that's a good way to study.

At least 1 means I can either have all 3 know Java, just 2 know Java, or only 1 know Java.
Again, extracting information from my venn diagram, there are 6 people who know both Java and Assembly, and 10 people who know Assembly but not Java.

For 1 that knows Java: (6 choose 1)(10 choose 2)
For 2 that know Java: (6 choose 2)(10 choose 1)
For 3 that know Java: (6 choose 3)(10 choose 0)

So then the probability would be [(6 choose 1)(10 choose 2) + (6 choose 2)(10 choose 1) + (6 choose 3)(10 choose 0) / (16 choose 3)]
Yes you are right; and what you are doing is evaluating a special case of the so-called hypergeometric distribution; see, eg.,
http://en.wikipedia.org/wiki/Hypergeometric_distribution or
http://mathworld.wolfram.com/HypergeometricDistribution.html

As I said already, a slightly easier way in this case is to do the complement: we start with N = 16 people (who know Assembly) and of which M = 16 - 6 = 10 do not know Java. So, to find P(all 3 do not know Java), proceed as follows.
P(first person does not know Java) = 10/16.
Now we are left with 15 people, among which 9 do not know Java, so
P(second does not know Java | first does not know Java) = 9/15.
Now we are left with 14 people, among which 8 do not know Java, so
P(third does not know Java | first two do not know Java) = 8/14.
Altogether, the answer we want is
P(all three do not know Java) = (10/16)(9/15)(8/14), and P(at least one knows Java) = 1 - (10/16)(9/15)(8/14).

The "logic" of such successive-choice probabilities is really what lies at the back of the hypergeometric distribution.
 
  • Like
Likes izelkay
  • #17
Ray Vickson said:
Yes you are right; and what you are doing is evaluating a special case of the so-called hypergeometric distribution; see, eg.,
http://en.wikipedia.org/wiki/Hypergeometric_distribution or
http://mathworld.wolfram.com/HypergeometricDistribution.html

As I said already, a slightly easier way in this case is to do the complement: we start with N = 16 people (who know Assembly) and of which M = 16 - 6 = 10 do not know Java. So, to find P(all 3 do not know Java), proceed as follows.
P(first person does not know Java) = 10/16.
Now we are left with 15 people, among which 9 do not know Java, so
P(second does not know Java | first does not know Java) = 9/15.
Now we are left with 14 people, among which 8 do not know Java, so
P(third does not know Java | first two do not know Java) = 8/14.
Altogether, the answer we want is
P(all three do not know Java) = (10/16)(9/15)(8/14), and P(at least one knows Java) = 1 - (10/16)(9/15)(8/14).

The "logic" of such successive-choice probabilities is really what lies at the back of the hypergeometric distribution.
Ah okay that makes sense, thank you.

Also, I looked at the wiki page you linked and came to the conclusion that the answer for part (e) is:

(45 choose 3)(15 choose 2) / (60 choose 5)

Since we're picking a team of 5 out of all 60 employees, 60 choose 5 is the sample space. Exactly 3 are programmers and since there are 45 programmers, (45 choose 3). Then the remaining 2 do not know any programming. 60 - 45 = 15 employees do not know any programming, so (15 choose 2).

Is that correct?
 
  • #18
izelkay said:
the answer for part (e) is:

(45 choose 3)(15 choose 2) / (60 choose 5)
Yes - well done.
 
  • Like
Likes izelkay
  • #19
Okay, that's all for now. Thank you all for your help, I feel I have a better understanding of problems like this now.
 
  • #20
Just came by to thank y'all again for your help. The final had similar problems to the one I posted here, and I knew how to do almost all of them:
lGK8Lia.png

:)
 
  • Like
Likes vela

Related to What is the Probability of Knowing Multiple Programming Languages?

What is simple probability?

Simple probability is the likelihood or chance of an event occurring. It is calculated by dividing the number of favorable outcomes by the total number of possible outcomes.

How do you calculate simple probability?

To calculate simple probability, divide the number of favorable outcomes by the total number of possible outcomes. The result will be a decimal or fraction between 0 and 1, which can also be represented as a percentage.

What is the difference between theoretical and experimental probability?

Theoretical probability is based on mathematical calculations and assumes that all outcomes are equally likely. Experimental probability is based on actual data collected from experiments or real-life events. It may differ from theoretical probability due to chance or other factors.

What is the sample space in simple probability?

The sample space is the set of all possible outcomes of an event. It includes all the possible outcomes, whether they are favorable or not.

Can the probability of an event be greater than 1?

No, the probability of an event cannot be greater than 1. This would mean that the event is certain to occur, which is not possible. The probability of an event can range from 0 to 1, where 0 means the event is impossible and 1 means the event is certain to occur.

Similar threads

Replies
4
Views
1K
Replies
12
Views
1K
Replies
7
Views
2K
Replies
12
Views
917
Replies
13
Views
4K
Replies
8
Views
4K
Back
Top