<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Monte Carlo | The Logos</title><link>https://thelogos.dev/tags/monte-carlo/</link><description>AI-friendly Korean/English knowledge hub designed for fast crawling while remaining welcoming to human visitors.</description><generator>Hugo 0.148.2</generator><language>ko-KR</language><managingEditor/><webMaster/><lastBuildDate>Tue, 16 Jun 2026 12:44:55 +0000</lastBuildDate><atom:link href="https://thelogos.dev/tags/monte-carlo/index.xml" rel="self" type="application/rss+xml"/><item><title>MCMC: 복잡한 확률분포를 산책으로 이해하는 방법</title><link>https://thelogos.dev/posts/mcmc/</link><pubDate>Tue, 16 Jun 2026 00:20:00 +0900</pubDate><dc:creator>DaeYoung Kim</dc:creator><category>engineering</category><category>MCMC</category><category>Markov Chain</category><category>Monte Carlo</category><category>베이지안</category><category>확률론</category><category>마코프 확장</category><guid isPermaLink="true">https://thelogos.dev/posts/mcmc/</guid><description>&lt;div
class="ai-summary-box my-6 p-5 rounded-2xl bg-indigo-50/50 dark:bg-slate-800/50 backdrop-blur-sm border border-indigo-100 dark:border-indigo-500/20 shadow-sm relative overflow-hidden group">
&lt;div
class="absolute inset-0 bg-gradient-to-br from-indigo-500/5 to-purple-500/5 opacity-0 group-hover:opacity-100 transition-opacity duration-500 pointer-events-none">
&lt;/div>
&lt;div class="relative z-10 flex items-start gap-4">
&lt;div class="flex-1">
&lt;div class="flex items-center gap-2 mb-2">
&lt;span
class="inline-flex items-center rounded-md bg-indigo-100 px-2.5 py-1 text-xs font-bold text-indigo-700 dark:bg-indigo-500/20 dark:text-indigo-300 ring-1 ring-inset ring-indigo-700/10 dark:ring-indigo-400/20 shadow-sm">
&lt;svg class="w-3.5 h-3.5 mr-1.5" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
&lt;path d="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6">&lt;/path>
&lt;/svg>
AI 요약
&lt;/span>
&lt;/div>
&lt;div class="text-slate-700 dark:text-slate-300 text-sm md:text-base leading-relaxed break-keep [&amp;>p]:m-0">
MCMC는 목표 분포가 높은 곳에 더 오래 머무는 마코프 체인을 만들어 복잡한 분포의 샘플을 얻는 방법이다. 제안 폭이 작으면 이동은 잘 받아들여지지만 천천히 섞이고, 너무 크면 거절이 많아져 탐색이 멈춘다. 수락률, 방문 빈도, 최근 경로를 함께 보면 샘플링 품질을 직관적으로 판단할 수 있다.
&lt;/div>
&lt;/div>
&lt;/div>
&lt;/div>
&lt;h2 id="인터랙티브-인포그래픽">인터랙티브 인포그래픽&lt;/h2>
&lt;p>제안 폭과 스텝 수를 조정하면 체인이 얼마나 잘 섞이는지 볼 수 있다. 목표 분포, 실제 방문 빈도, 최근 이동 경로가 한 화면에 겹쳐진다.&lt;/p></description><content:encoded>&lt;![CDATA[<div class="ai-summary-box my-6 p-5 rounded-2xl bg-indigo-50/50 dark:bg-slate-800/50 backdrop-blur-sm border border-indigo-100 dark:border-indigo-500/20 shadow-sm relative overflow-hidden group"><div class="absolute inset-0 bg-gradient-to-br from-indigo-500/5 to-purple-500/5 opacity-0 group-hover:opacity-100 transition-opacity duration-500 pointer-events-none"/><div class="relative z-10 flex items-start gap-4"><div class="flex-1"><div class="flex items-center gap-2 mb-2"><span class="inline-flex items-center rounded-md bg-indigo-100 px-2.5 py-1 text-xs font-bold text-indigo-700 dark:bg-indigo-500/20 dark:text-indigo-300 ring-1 ring-inset ring-indigo-700/10 dark:ring-indigo-400/20 shadow-sm"><svg class="w-3.5 h-3.5 mr-1.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>
AI 요약</span></div><div class="text-slate-700 dark:text-slate-300 text-sm md:text-base leading-relaxed break-keep [&>p]:m-0">
MCMC는 목표 분포가 높은 곳에 더 오래 머무는 마코프 체인을 만들어 복잡한 분포의 샘플을 얻는 방법이다. 제안 폭이 작으면 이동은 잘 받아들여지지만 천천히 섞이고, 너무 크면 거절이 많아져 탐색이 멈춘다. 수락률, 방문 빈도, 최근 경로를 함께 보면 샘플링 품질을 직관적으로 판단할 수 있다.</div></div></div></div><h2 id="인터랙티브-인포그래픽">인터랙티브 인포그래픽</h2><p>제안 폭과 스텝 수를 조정하면 체인이 얼마나 잘 섞이는지 볼 수 있다. 목표 분포, 실제 방문 빈도, 최근 이동 경로가 한 화면에 겹쳐진다.</p><style>
.thelogos-interactive-frame-shell {
box-sizing: border-box;
width: 100%;
max-width: 100%;
margin: 36px 0 56px;
overflow: hidden;
border: 1px solid rgba(15, 23, 42, 0.16);
border-radius: 18px;
background: #07111f;
box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
}
.dark .thelogos-interactive-frame-shell,
body.dark .thelogos-interactive-frame-shell {
border-color: rgba(255, 255, 255, 0.12);
box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}
.thelogos-interactive-frame-shell iframe {
display: block;
width: 100%;
min-height: 680px;
border: 0;
background: #07111f;
}
.thelogos-interactive-frame-fallback {
padding: 16px 18px;
margin: 0;
color: #d7e5f5;
background: #0f1d33;
}
@media (max-width: 640px) {
.thelogos-interactive-frame-shell {
margin-top: 28px;
margin-bottom: 44px;
border-radius: 14px;
}
.thelogos-interactive-frame-shell iframe {
min-height: 760px;
}
}</style><div class="thelogos-interactive-frame-shell"><iframe src="/markov-extensions/mcmc/" title="MCMC: 복잡한 확률분포를 산책으로 이해하는 방법 인터랙티브 인포그래픽" loading="lazy" scrolling="no"/><noscript><p class="thelogos-interactive-frame-fallback">
자바스크립트가 꺼져 있으면 인터랙티브 인포그래픽이 표시되지 않을 수 있다.<a href="/markov-extensions/mcmc/">인포그래픽 페이지를 직접 열기</a></p></noscript></div><script>
(function () {
const shell = document.currentScript.previousElementSibling;
const iframe = shell && shell.querySelector('iframe');
if (!iframe) return;
function currentTheme() {
return (document.documentElement.classList.contains('dark') || document.body.classList.contains('dark')) ? 'dark' : 'light';
}
function syncTheme() {
iframe.contentWindow?.postMessage({
type: 'thelogos-interactive-theme',
theme: currentTheme()
}, window.location.origin);
}
window.addEventListener('message', function (event) {
if (event.origin !== window.location.origin || event.source !== iframe.contentWindow || event.data?.type !== 'thelogos-interactive-height') return;
const nextHeight = Math.max(680, Math.ceil(Number(event.data.height) || 0));
iframe.style.height = nextHeight + 'px';
});
iframe.addEventListener('load', syncTheme);
const observer = new MutationObserver(syncTheme);
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });
observer.observe(document.body, { attributes: true, attributeFilter: ['class'] });
syncTheme();
}());</script><h2 id="1-요약-executive-summary">1. 요약 (Executive Summary)</h2><p>확률분포를 안다는 것은 단순히 평균 하나를 안다는 뜻이 아니다. 어떤
값이 얼마나 그럴듯한지, 불확실성이 어느 구간에 몰려 있는지, 여러 변수가
함께 움직일 때 어떤 조합이 가능한지를 이해한다는 뜻이다.
문제는 현실의 많은 분포가 너무 복잡하다는 점이다. 식은 쓸 수 있지만
적분이 어렵거나, 차원이 너무 높아서 전체 모양을 직접 계산할 수 없는
경우가 많다. MCMC는 이 문제를 다른 방식으로 푼다.</p><blockquote><p>“전체 지도를 한 번에 그릴 수 없다면, 그 지형을 오래 걸어 다니며 자주
방문한 곳을 기록하자.”</p></blockquote><h2 id="2-이름의-의미">2. 이름의 의미</h2><p>MCMC는 두 단어가 합쳐진 말이다.</p><ul><li>Markov Chain: 다음 위치가 현재 위치에만 의존하는 확률적 이동
과정</li><li>Monte Carlo: 무작위 표본을 많이 뽑아 계산하는 방법
즉 MCMC는 마코프 체인을 이용해 몬테카를로 샘플을 만드는 방법이다.</li></ul><h2 id="3-직관-분포-위를-걷는-사람">3. 직관: 분포 위를 걷는 사람</h2><p>산의 높이가 확률밀도라고 생각해 보자. 높은 산은 그 값이 더
그럴듯하다는 뜻이고, 낮은 평지는 덜 그럴듯하다는 뜻이다. MCMC의 산책자는
높은 곳으로 가는 제안은 잘 받아들이고, 낮은 곳으로 내려가는 제안은
가끔만 받아들인다. 그렇게 하면 산책자는 자연스럽게 높은 확률 영역에 오래
머문다.
오랜 시간이 지나면 산책자의 방문 빈도가 목표 분포의 모양과
비슷해진다.</p><h2 id="4-간단한-알고리즘">4. 간단한 알고리즘:</h2><p>Metropolis-Hastings</p><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>1. 현재 위치 x에서 시작한다.</span></span><span style="display:flex;"><span>2. 주변의 새 위치 x'를 제안한다.</span></span><span style="display:flex;"><span>3. target(x') / target(x)를 계산한다.</span></span><span style="display:flex;"><span>4. 새 위치가 더 그럴듯하면 이동한다.</span></span><span style="display:flex;"><span>5. 덜 그럴듯해도 일정 확률로 이동한다.</span></span><span style="display:flex;"><span>6. 이 과정을 오래 반복한다.</span></span></code></pre></div><p>핵심은 덜 좋은 위치로도 가끔 이동한다는 점이다. 그래야 한 봉우리에
갇히지 않고 전체 분포를 탐색할 수 있다.</p><h2 id="5-왜-필요한가">5. 왜 필요한가</h2><p>베이지안 추론에서는 사전분포와 데이터 likelihood를 결합해 사후분포를
만든다. 하지만 이 사후분포는 대부분 손으로 계산하기 어렵다. MCMC는 이
사후분포에서 직접 샘플을 뽑아 평균, 신뢰구간, 예측분포를 근사한다.
물리학에서는 입자 시스템의 평형 상태를 시뮬레이션할 수 있고,
금융에서는 복잡한 위험분포나 파라미터 불확실성을 탐색할 수 있다.</p><h2 id="6-주의할-점">6. 주의할 점</h2><p>MCMC는 샘플을 준다고 해서 자동으로 정확한 것은 아니다. 체인이 목표
분포에 충분히 도달했는지, 여러 봉우리를 잘 오가고 있는지, 샘플 간 상관이
너무 높지 않은지 확인해야 한다. 이를 수렴 진단, mixing, effective sample
size라고 부른다.
또한 제안 폭이 중요하다. 너무 작으면 천천히 움직이고, 너무 크면
대부분 거절된다. 현대 도구인 Stan은 Hamiltonian Monte Carlo와 NUTS를
사용해 고차원 분포에서 더 효율적으로 이동한다.</p><h2 id="7-결론">7. 결론</h2><p>MCMC는 복잡한 분포를 직접 계산하는 대신, 그 분포가 높은 곳에 오래
머무는 확률적 산책자를 만든다. 이 아이디어는 단순하지만 강력하다.
“모르는 것을 확률적으로 탐색한다”는 점에서 현대 통계학과 머신러닝의 핵심
사고방식 중 하나다.</p><h2 id="참고자료">참고자료</h2><ul><li>MathWorks, “Kalman Filter - MATLAB &amp; Simulink”, 확인일:
2026-06-16,<a href="https://www.mathworks.com/discovery/kalman-filter.html">https://www.mathworks.com/discovery/kalman-filter.html</a></li><li>Alex Becker, “Kalman Filter Explained Through Examples”, 확인일:
2026-06-16,<a href="https://kalmanfilter.net/">https://kalmanfilter.net/</a></li><li>Stan Reference Manual, “MCMC Sampling”, 확인일: 2026-06-16,<a href="https://mc-stan.org/docs/reference-manual/mcmc.html">https://mc-stan.org/docs/reference-manual/mcmc.html</a></li><li>MIT OpenCourseWare, “Lecture 25: Random Walks”, 확인일: 2026-06-16,<a href="https://ocw.mit.edu/courses/6-042j-mathematics-for-computer-science-fall-2010/resources/lecture-25-random-walks/">https://ocw.mit.edu/courses/6-042j-mathematics-for-computer-science-fall-2010/resources/lecture-25-random-walks/</a></li><li>Stanford CS221, “Markov Decisions”, 확인일: 2026-06-16,<a href="https://stanford.edu/~cpiech/cs221/handouts/markovDecisions.html">https://stanford.edu/~cpiech/cs221/handouts/markovDecisions.html</a></li><li>Bailey, D. H. &amp; López de Prado, M., “The Deflated Sharpe Ratio:
Correcting for Selection Bias, Backtest Overfitting and Non-Normality”,
Journal of Portfolio Management, 2014; SSRN 확인일: 2026-06-16,<a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2460551">https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2460551</a></li></ul>
]]></content:encoded></item></channel></rss>