S10 Day 0: Mean, Median, and Mode

1 개요[ | ]

Day 0: Mean, Median, and Mode
0일차: 평균, 중앙값, 최빈값
해커랭크 10 Days of Statistics
문제 C C++ C# Go Java node.js Perl PHP Python R Ruby
0-1 Day e
S10 Day 0: Mean, Median, and Mode
S10 Day 0: Weighted Mean
S10 Day 1: Quartiles
S10 Day 1: Interquartile Range
S10 Day 1: Standard Deviation

2 Python[ | ]

import numpy as np
from scipy import stats
n = int(input())
nums = list(map(int, input().split()))
print( np.mean(nums) )
print( np.median(nums) )
print( int(stats.mode(nums)[0]) )
# 43900.6
# 44627.5
# 4978

3 R[ | ]

a <- scan(file="stdin")[-1]
cat( sum(a)/length(a), "\n" )
cat( median(a), "\n" )
cat( which.max(tabulate(a)), "\n" )
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}