What is the Probability of Knowing Multiple Programming Languages?

  • Thread starter Thread starter izelkay
  • Start date Start date
  • Tags Tags
    Probability
Click For Summary

Homework Help Overview

The discussion revolves around calculating probabilities related to programmers who know multiple programming languages, specifically Java, C, and Assembly. The original poster is attempting to apply Bayes' theorem and combinatorial methods to determine various probabilities based on the knowledge of these languages.

Discussion Character

  • Exploratory, Mathematical reasoning, Assumption checking

Approaches and Questions Raised

  • Participants discuss the need to accurately define the sample space and avoid double counting in probability calculations. There are suggestions to use Venn diagrams to visualize the relationships between different groups of programmers.

Discussion Status

Participants are actively engaging with the problem, exploring different methods to calculate probabilities. Some have provided guidance on using Venn diagrams and combinatorial reasoning, while others are questioning the assumptions made about the sample space and the definitions of the groups involved.

Contextual Notes

There is an emphasis on ensuring that all calculations consider the correct intersections of programming knowledge. The original poster expresses uncertainty about the numbers involved and the implications of their calculations, indicating a need for clarification on the definitions of the groups being analyzed.

izelkay
Messages
115
Reaction score
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
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   Reactions: izelkay
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?
 
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?
 
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
 
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:
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   Reactions: izelkay
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:
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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: 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   Reactions: vela

Similar threads

Replies
86
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 13 ·
Replies
13
Views
5K
  • · Replies 8 ·
Replies
8
Views
5K
Replies
2
Views
3K
Replies
3
Views
3K
Replies
5
Views
4K