본문 바로가기
Programming/python

파이썬으로 정규분포그래프 그리기 python normal distribution

by 르미르미 2021. 6. 20.

정규분포란? (normal distribution)

(학교 다닐 때 이거 왜 똑같은 거 맨날 배워 이랬는데 이렇게 하나도 기억이 안난다고????)

 

확률 분포에서 가장 중요하게 다루는 분포인데 

그렇다면 확률 분포란?

시행에서 확률변수가 어떤 값을 가질지에 대한 확률. 

아무튼 정규분포란 무작위 표본 추출을 통해 도출한 확룰 밀도 곡선에 극한을 적용해 만든 것을 형태로 적립한 것이다.

 

너무 어려우니 이론은 넘어가고 바로 실전으로 가도록 하겠다. 

 

어떤 실험 결과가 있는데 그 실험 결과를 구간을 나누어 분포 정도를 보고자 할 때 사용하면 된다.

 

전혀 기억나지 않는 다양한 공식이 있지만 

 

다 패스하고 seaborn을 이용하면 참 좋다. 

 

(seaborn 이란? matplotlib에 기반하여 제작된 파이썬 데이터 시각화 라이브러리. )

 

 

import seaborn as sns

sns.displot(data)

displot을 이용하면 위와 같이 bar 형태의 그래프를 얻을 수 있다. 

data 는 dataframe, series, list, 등이 가능하다. 

 

sns.displot(data, kind='kde')

위와 같이 kind='kde' 를 추가하면 

이렇게 line 형태의 그래프를 얻을 수 있다. 

 

세상 참 좋다. 

 

 

 

seaborn.distplot — seaborn 0.11.1 documentation

DEPRECATED: Flexibly plot a univariate distribution of observations. Warning This function is deprecated and will be removed in a future version. Please adapt your code to use one of two new functions: displot(), a figure-level function with a similar flex

seaborn.pydata.org

 

 

Visualizing distributions of data — seaborn 0.11.1 documentation

A histogram aims to approximate the underlying probability density function that generated the data by binning and counting observations. Kernel density estimation (KDE) presents a different solution to the same problem. Rather than using discrete bins, a

seaborn.pydata.org

 

댓글