Python statistics.variance() 메서드
예시
데이터 샘플에서 분산을 계산합니다.
# Import statistics Library
import statistics
# Calculate
the variance from a sample of data
print(statistics.variance([1, 3, 5, 7, 9, 11]))
print(statistics.variance([2,
2.5, 1.25, 3.1, 1.75, 2.8]))
print(statistics.variance([-11, 5.5, -3.4,
7.1]))
print(statistics.variance([1, 30, 50, 100]))
정의 및 사용
이 statistics.variance()
방법은 모집단의 데이터 표본에서 분산을 계산합니다.
분산이 크면 데이터가 분산되어 있음을 나타내고, 분산이 작으면 데이터가 평균 주위에 밀집되어 있음을 나타냅니다.
팁: 전체 모집단의 분산을 계산하려면 statistics.pvariance()
방법을 살펴보십시오.
통사론
statistics.variance(data, xbar)
매개변수 값
Parameter | Description |
---|---|
data | Required. The data values to be used (can be any sequence, list or iterator) |
xbar | Optional. The mean of the given data. If omitted (or set to None), the mean is automatically calculated |
참고: 데이터 의 값이 2개 미만이면 StatisticsError를 반환합니다 .
기술적 세부 사항
반환 값: | float 주어진 데이터의 표본 분산을 나타내는 값 |
---|---|
파이썬 버전: | 3.4 |