728x90
반응형

16. P(A) = 0.54 P(B) = 0.4 P(A M B) = 0.23 A회사나 B회사 제품만을 선호할 확률

 

P(B_c M A) = 0.54-0.23 = 0.31

P(A_c M B) = 0.4 - 0.23 = 0.17

 

0.31 + 0.17 = 0.48

 

17.  심장 박동이 정상이고, 저혈압인 환자가 선정될 확률

 

A = '고혈압' 

B = '저혈압'

C = '혈압정상'

 

D = '심박 정상'

E = '심박비정상'

 

P(A) = 0.14

P(B) = 0.22

P(C) = 0.64

 

P(D) = 0.85

P(E) = 0.15

 

 

P(A|D)  = 1/3 = P(A M D) / P(D) = P(A)P(D|A)

P(E|C) = 1/8 = P(E M C) / P(C)

 

P(D M C) = P(C)P(D|C) = P(D)P(C|D) 

 

0.64 * P(D|C) = 0.85 * P(C|D)

 

 

18.  4명임의 선택 ,확률 구하기

 

Rh(+) O형은 27.3%

print(math.pow(0.273 , 4))
print(math.pow(0.727 , 4))
print(1- math.pow(0.727 , 4))

 

1> 4명이 모두 Rh(+) O형이다.

 

(27.3%)**4  = 0.00555

 

2>4명 중 그 누구도 Rh(+) O형이 아니다.

 

(72.7%)**4 = 0.2793

 

3>적어도 1명이 Rh(+)O 형이다.

 

1-(72.7%)**4 = 0.7206

 

 

19. 5지선다형 3문제

 

1> 3문제중 어느 하나를 맞을 확률

 

a = np.arange(2)
b = itertools.product(a,  repeat= 3)

print(list(itertools.product(a,  repeat= 3)))

c = list(filter(lambda x : collections.Counter(x).most_common()[0][0] == 0 and collections.Counter(x).most_common()[0][1] ==2 , b))
print(c)
print( len(c) * (1/5)*(4/5)*(4/5) )

[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)]
[(0, 0, 1), (0, 1, 0), (1, 0, 0)]
0.3840000000000001

 

 

2> 처음 2문제를 맞을 확률

 

1/5 * 1/5 = 0.04

 

3> 모두 다 틀릴 확률

 

1 - 0.4879 = 0.5121

 

4>적어도 하나를 맞을 확률

 

1- (4/5)**3 = 0.4879

 

5> 정확히 한 문제를 맞았다고 할때 , 맞은 문제가 2번째 문제일 확률

 

b = itertools.product(a,  repeat= 3)
e = list(filter(lambda x : collections.Counter(x).most_common()[0][0] ==1  and collections.Counter(x).most_common()[0][1] ==2 and x[1] == 1, b))

print(e)
print( len(e) * (1/5)*(4/5))

[(0, 1, 1), (1, 1, 0)]
0.32000000000000006

 

 

20. 비복원 추출에 의한 3명의 학생 무작위 선정 ==> 남학생의 수가 여학생의 수보다 많을 확률

 

man = [i for i in range(8)]
girl = [j for j in range(8,15)]
#P(man > girl)

a = np.arange(2)

b = itertools.combinations_with_replacement(a , 3)
c = list(filter(lambda x : collections.Counter(x).most_common()[0][0] == 0 , b))
d=0
for i in c:
    print(i)
    d += len(list(itertools.combinations(np.arange(8) , collections.Counter(i).most_common()[0][1])))* len(list(itertools.combinations(np.arange(7) , (3-collections.Counter(i).most_common()[0][1]))))
    print(d)

e = d/ len(list(itertools.combinations(np.arange(15) , 3)))
print(e)

(0, 0, 0)
56


(0, 0, 1)
252


0.5538461538461539
0.5384615384615384

 

 

0이 남자 , 1이 여자

 

출처 :  [쉽게 배우는 생활속의 통계학]  [북스힐 , 이재원] 

※혼자 공부 정리용

728x90
반응형

+ Recent posts