728x90
반응형

1. 이산확률변수 x의 확률분포

X = np.arange(-2,3)
p_x = [0.15 , 0.25 , '-' , 0.25 , 0.3]

A = pd.DataFrame([p_x] , columns = X)
A.index = ['P(X = x)']
A.columns.names = ['X']
A

이산확률변수의 확률분포표

B =  (1-  A.iloc[ [0], [0,1,3,4]].sum(axis=1))
B
A.loc['P(X = x)' , 0] = (1-  A.iloc[ [0], [0,1,3,4]].sum(axis=1))[0]
A

==> B의 dtype 은 float64이다. 

==> DataFrame안에서 계산한 결과값을 구하려면 B를 리스트라 생각하자.

최종 이산확률변수의 확률분포표

https://knowallworld.tistory.com/240

 

표본,모표본★평균과 분산★기초통계학-[Chapter05 - 이산확률분포-02]

1. 평균 ==> 이산확률변수의 확률 히스토그램 ==> 상대도수히스토그램과 유사 But. 상대도수히스토그램은 n개의 자료 값에 대한 표본 설명 확률 히스토그램은 실험에서 발생할 수 있는 모든 경우에

knowallworld.tistory.com

b = A.iloc[0,:].tolist()
print(b)
print(X)
mean = 0
vars , vars2 =0 , 0
for i in range(len(X)):
    mean += (X[i]*b[i])
mean = round(mean,2)
print(mean)
for i in range(len(X)):
    vars += (math.pow(X[i] , 2) * b[i])
    print((math.pow(X[i] , 2)  , b[i]  , math.pow(X[i] , 2) * b[i]))
vars = vars - math.pow(mean,2)
print("vars : {}".format(vars))
print(round(vars,2))
print(math.sqrt(vars))

 

 

1> P(X = 0) 

 

==> 0.05

 

2> 평균(뮤)와 분산을 구하라

 

E(X) = 0.3 ==> x*f(x)

분산 = 2.21 ==> 시그마 x**2(f(x))  - E(X)**2

표준편차 = 1.49

 

 

2. X~ B(8 , 0.45) ==> 8번시행, 45%의 성공률

https://knowallworld.tistory.com/241

 

이항분포식★이항실험★이항분포의 평균,분산★베르누이시행★기초통계학-[Chapter05 - 이산확률

1. 이항분포 ==> 많이 사용하는 확률 모형 : 이항분포, 푸아송분포 , 초기하분포 1. 이항실험(Bionomial Experiment) ==> 실험은 N번의 시행 ==> 실험 결과는 성공(S) , 실패(F) ==> 성공 확률 : p , 실패 확률 : q

knowallworld.tistory.com

1> P(X=4) 

 

n = 8 , p = 0.45

print(len(list(itertools.combinations(np.arange(8) , 4))) * math.pow(0.45 , 4) * math.pow(0.55 , 4)     )

==> 이항분포의 확률 함수 : nCx * (p**x) * (q ** n-x)

 

P(X = 4) = 0.2626

 

2> P(X != 3) = 1- P(X=3) = 1 - 0.2568 = 0.74317

 

P(X=3) = 0.2568

 

3>P(X<=5) = 0.9115

 

4> P(X>=6) = 1 - P(X<=5) = 0.0885

 

5> 평균(뮤) = np = 8 *0.45 =  3.6

 

6> 분산 = npq = 1.98 , 표준편차 = 1.407

 

7> P( m -o <= X <= m + o) = P( 2.193 <= X <= 5.007) = P(3<= X<=5) = 1- P(X<=2) - P(X>=6) = P(X<=5) - P(X<=2) 

1- 0.2201 - 0.0885 = 0.6914

 

P(X<=2) = 0.2201

 

8> P( m -2o <= X <= m + 2o) = P(0.786 <= X <= 6.414) = P(1<= X <= 6) = P(X<=6) - P(X=0)  =0.9819 - 0.0084= 0.9735

 

P(X=0) = 0.0084

 

 

3. X~ P(5) ==> 평균(뮤) = 5

https://knowallworld.tistory.com/242

 

푸아송분포★기초통계학-[Chapter05 - 이산확률분포-04]

1.푸아송 분포 ==> 이항분포에 대한 확률을 계산하기 위하여 누적이항확률표 사용 ==> but. 시행(n)이 30보다 큰 경우의 확률표 X ==> 시행(n)이 30보다 클 경우의 확률 근사값 구할 수 있다. 1> 확률 실

knowallworld.tistory.com

==> 푸아송 분포

f(x) = (뮤**x * e**(-뮤)) / x!

 

1> P(X=3) = P(X<=3) - P(X<=2) = 0.265 - 0.125 = 0.140

 

2>P(X <= 4) = 0.440

 

3> P(X>=10) = 1-P(X<=9) = 1 -0.968 = 0.032

 

4>P(4<=X<=8) = P(X<=8) - P(X<=3) =0.932 - 0.265= 0.667

 

==> 누적푸아송확률분포표 참고

 

 

4. N = 10 , r = 6 , n =5인 초기하분포 ==> 빨간공 6개 파란공 4개 , 5번 뽑아보자

https://knowallworld.tistory.com/245

 

★초기하분포★기하분포★이산균등분포★기초통계학-[Chapter05 - 이산확률분포-06]

1. 이산균등분포(Discrete Uniform Distribution) 1> 동전을 한 번 던져서 앞면이 나온 횟수를 X ==> p(x) = 1/2 , x= 0 ,1 2> 주사위를 한 번 던질 때 나온 눈의 수를 확률 변수 X라 하면 ==> p(x) = 1/6 , x =1 , 2, 3, 4, 5,

knowallworld.tistory.com

1> P(X = 3) ==> 빨간공 3개일때

 

X ~ P(10 , 6 , 5 )

 

p  = 6/10 = 0.6

q  = 0.4

b = len(list(itertools.combinations(np.arange(6) , 3))) * len(list(itertools.combinations(np.arange(4) , 2))) / len(list(itertools.combinations(np.arange(10) , 5)))
print(b)

P(X=3) = 6C3 * 4C2 / 10C5 = 0.47619

 

 

2> P(X=4) =   6C4 * 4C1 / 10C5 = 0.2380

 

3>P(X<=4) = P(X=0) + P(X=1) + P(X=2) + P(X=3) + P(X=4)  =  = 0.9762

b= 0

for x in range(5):
    print(x)

    c = len(list(itertools.combinations(np.arange(6) , x))) * len(list(itertools.combinations(np.arange(4) , 5-x))) / len(list(itertools.combinations(np.arange(10) , 5)))
    print(c)
    b+=c
print(b)

4> P(X>3) = 1- P(X<=3) = 0.262

 

 

b= 0

for x in range(4):
    print(x)

    c = len(list(itertools.combinations(np.arange(6) , x))) * len(list(itertools.combinations(np.arange(4) , 5-x))) / len(list(itertools.combinations(np.arange(10) , 5)))
    print(c)
    b+=c
print(1-b)

 

5. X ~ G(0.6) ==> 성공할때까지 했을때 성공할 확률

https://knowallworld.tistory.com/245

 

★초기하분포★기하분포★이산균등분포★기초통계학-[Chapter05 - 이산확률분포-06]

1. 이산균등분포(Discrete Uniform Distribution) 1> 동전을 한 번 던져서 앞면이 나온 횟수를 X ==> p(x) = 1/2 , x= 0 ,1 2> 주사위를 한 번 던질 때 나온 눈의 수를 확률 변수 X라 하면 ==> p(x) = 1/6 , x =1 , 2, 3, 4, 5,

knowallworld.tistory.com

==> 기하분포 ==> x는 1부터다!

 

1> P(X=3) 

 

p = 0.6 * (0.4 ** (3-1) ) =   0.096

 

2> P(X<=4) = P(X=1) + P(X=2) + P(X=3) + P(X=4)  = 0.9743

 

3>P(X>=10) = 1- P(X<=9) = 0.00026

 

4> P(4<=X <=8) = P(X=4) + P(X=5) P(X=6) P(X=7) P(X=8) = 0.0633

 

 

 

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

※혼자 공부 정리용

728x90
반응형

+ Recent posts