본문 바로가기

분류 전체보기

(51)
[데이터 과학] 통계 (Statistics) 통계란? 일상생활이나 여러 가지 현상에 대한 자료를 한눈에 알아보기 쉽게 수치로 나타내는 것이다. 어떠한 웹 사이트에서 각 사용자들이 몇 명의 친구를 갖고 있는지 설명해 달라고 요청했다고 하자. 데이터 수가 작다면 사용자와 친구간의 데이터를 그대로 보여주면 되겠지만, 데이터가 많다면 데이터를 다루는 것도 불편하고 이해하기도 힘들 것이다. 이럴 때 통계를 사용하면 데이터를 정제해서 중요한 정보만 전달해줄 수 있다. from collections import Counter # 사용자의 친구수를 히스토그램으로 나타내기 num_friends = [100.0, 49, 41, 40, 25, 21, 21, 19, 19, 18, 18, 16, 15, 15, 15, 15, 14, 14, 13, 13, 13, 13, 12..
벡터(Vector) 란? 1. 벡터란 간단히 말하면, 벡터(vector) 는 벡터끼리 더하거나 상수(scalar) 와 곱해지면 새로운 벡터를 생성하는 개념적인 도구이다. 더 자세하게는, 벡터는 어떤 유한한 차원의 공간에 존재하는 점들이다. 대부분의 데이터, 특히 숫자로 표현된 데이터는 벡터로 표현할 수 있다. 수많은 사람들의 키, 몸무게, 나이에 대한 데이터가 주어졌다고 해보자. 그렇다면 주어진 데이터를 (키, 몸무게, 나이) 로 구성된 3차원 벡터로 표현할 수 있을 것이다. 또 다른 예로, 시험을 네 번 보는 수업을 가르친다면 각 학생의 성적을 (시험1 점수, 시험2 점수, 시험3 점수, 시험4 점수)로 구성된 4차원 벡터로 표현할 수 있을 것이다. 벡터를 가장 간단하게 표현하는 방법은 여러 숫자의 리스트로 표현하는 것이다. ..
[Leetcode] 443. String Compression Given an array of characters chars, compress it using the following algorithm: Begin with an empty string s. For each group of consecutive repeating characters in chars: If the group's length is 1, append the character to s. Otherwise, append the character followed by the group's length. The compressed string s should not be returned separately, but instead be stored in the input character array..
[Leetcode] 1197. Minimum Knight Moves In an infinite chess board with coordinates from -infinity to +infinity, you have a knight at square [0, 0]. A knight has 8 possible moves it can make, as illustrated below. Each move is two squares in a cardinal direction, then one square in an orthogonal direction. Return the minimum number of steps needed to move the knight to the square [x, y]. It is guaranteed the answer exists. Example 1: ..
1283. Find the Smallest Divisor Given a Threshold Given an array of integers nums and an integer threshold, we will choose a positive integer divisor and divide all the array by it and sum the result of the division. Find the smallest divisor such that the result mentioned above is less than or equal to threshold. Each result of division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5)..
[Leetcode] 1396. Design Underground System Implement the class UndergroundSystem that supports three methods: checkIn(int id, string stationName, int t) A customer with id card equal to id, gets in the station stationName at time t. A customer can only be checked into one place at a time. checkOut(int id, string stationName, int t) A customer with id card equal to id, gets out from the station stationName at time t. getAverageTime(string..
[Leetcode] 381. Insert Delete GetRandom O(1) - Duplicates allowed Design a data structure that supports all following operations in average O(1) time. Note: Duplicate elements are allowed. insert(val): Inserts an item val to the collection. remove(val): Removes an item val from the collection if present. getRandom: Returns a random element from current collection of elements. The probability of each element being returned is linearly related to the number of s..
다중 우주론 (Multiverse) 다중 우주론은 우리 우주가 유일하고 독립적인 하나의 우주인 유니버스(Universe) 가 아니라, 다양한 가능성의 다수 우주인 멀티버스(Multiverse) 로 존재한다는 우주관이다. 시간과 공간적 측면에서 보면 다음과 같다. 시간적 측면 시간적 측면에서 다중 우주는 줄줄이 연결되어 있는 비엔나 소시지를 닮았다. 우주는 팽창과 수축을 무한히 반복하며 이어진다. 이러한 형태의 다중 우주를 특히 주기적 다중 우주라고 한다. 공간적 측면 공간적 측면에서 다중 우주의 모습은 이 비엔나소시지를 다 떼어내서 꼬치에 끼운 모습을 생각하면 된다. 특정 시간에 무수히 많은 우주가 동시에 존재하는 것이다. 이 우주들은 서로 완벽히 독립되어 있거나, 혹은 무수히 중첩되어 존재하는 것으로 해석된다. 하지만, 다중 우주를 시간..
big O vs big Ω vs big Θ O (Big O)학계에서 big-O 는 시간의 상한을 나타낸다. 배열의 모든 값을 출력하는 알고리즘은 O(N) 으로 표현할 수도 있지만, 이 외에 N 보다 큰 big-O 시간으로 표현할 수도 있다. 예를 들어, O(N2),O(N3),O(2N)O(N^2), O(N^3), O(2^N)O(N2),O(N3),O(2N) 도 모두 옳은 표현이다. 다시 말해 실제 알고리즘의 수행시간은 적어도 이들 중 하나보다 빠르기만 하면 된다.Ω (Big Omega)학계에서 Ω 는 하한을 나타낸다. 해당 알고리즘은 Ω 수행 시간보다 빠를 수 없다.Θ (Big Theta)학계에서 Θ 는 O 와 Ω 둘다를 의미한다. 즉, 어떤 알고리즘의 수행시간이 O(N) 이면서 Ω(N) 이라면, 이 알고리즘의 수행 시간을 Θ(N) 으로 표현할 수..
[책 리뷰] 카프카, 데이터 플랫폼의 최강자 카프카, 데이터 플랫폼의 최강자 국내도서 저자 : 고승범,공용준 출판 : 책만 2018.04.26 상세보기 2년전쯤 팀내에서 스터디로 진행했던 책이다. 사실 이런 유명하고 잘 만들어진 오픈소스류들은 문서가 워낙 잘 되어 있고 레퍼런스도 많아서 웬만한 책들은 이런 레퍼런스보다 못한 경우가 많았었던 경험이 있다. 특히 한국인 저자분이 쓴 책들은 아무래도 영어로 된 정보를 전달하는 경우가 많다보니 구성이 산만하다거나, 전달하고자 하는 내용이 깔끔하지 못한 경우가 많은데, 이책은 꽤나 잘 쓰여졌다. 내용의 전개가 상당히 깔끔하고 군더더기가 없다. 중복되는 내용이 반복해서 나오지도 않으며, 카프카의 단순 사용법 뿐만 아니라 다년간 운영에서 나오는 노하우와 고려해야할 점까지 나와있는 점이 매우 좋았다. 도큐먼트보다..