用马尔可夫逻辑避免决定论

发布于 2024-08-04 02:54:38 字数 510 浏览 6 评论 0原文

我今天刚刚开始阅读有关马尔可夫链生成器的更多信息,并且对构建马尔可夫链生成器的整个过程非常感兴趣。根据我的理解,未来的状态取决于过去到现在的统计状态。

示例:

世界你好。你好,多莉。世界你好。

在该来源中,大约 66% 的时间“World”跟在“Hello”之后。

如果情况总是如此,那么如何避免每次都输出相同的结果?统计出现次数不会随静态字符串而改变,所以我是否正确地假设不会生成任何变体,除非以某种方式修改源数据?

考虑到统计值,同时允许一定的灵活性,我如何才能从静态源获得变化?使用上面的示例,当“Dolly”仅在 33% 的情况下跟随“Hello”时,如何让我的生成器跟随“Hello”与“Dolly”?

我想我要问的是,我如何根据当前选择之后的单词的统计存在情况来确定下一个选择的概率?这样,“Dolly”出现的概率为 33%,而“World”出现的概率为 66% - 还是我完全迷失了?

I just began reading more about Markov Chain Generators today, and am really intrigued by the whole process of building one. From my understanding, the future state is dependent upon the statistical past states to the present.

Example:

Hello World. Hello Dolly. Hello World.

"World" follows "Hello" ~66% of the time in that source.

If that is always the case, how then do you avoid out-putting the same results each time? The statistical-occurrences won't change with a static string, so am I right to assume that no variants will every be generated, unless the source-data is modified in some way?

How could I get variations from a static-source, considering the statistical-values, yet allowing some flexibility? Using my example above, how do I allow my generator to follow "Hello" with "Dolly," when "Dolly" only follows "Hello" 33% of the time?

I guess what I'm asking is, How do I base the probability of my next selection on the statistical presence of the words that follow my present selection? That way, "Dolly" shows up 33% of the time, and "World" shows up 66% of the time - or am I completely lost here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

檐上三寸雪 2024-08-11 02:54:38

您使用随机数生成器来选择您要走的路径。您必须保存每个状态(这实际上是 N 个先前项目的历史记录)以及该状态的概率。然后你选择一个随机数并根据它决定你过渡到的下一个状态是什么。

在您的示例中,您有一个 N 为 1 的马尔可夫链,您将拥有一个看起来像这样的链结构:

<start> -> Hello : 1.0

Hello -> World. : 0.66666
Hello -> Dolly. : 0.33333

Dolly. -> Hello : 1.0

World. -> <end> : 0.5
World. -> Hello : 0.5

如果您当前的状态是 Hello,那么您的下一个可能的状态是 World。和 Dolly.. 生成一个 0 到 1 之间的随机数并选择 World。如果小于 0.666666,则选择 Dolly。

使用 N=2 马尔可夫链,您可以通过该输入获得几乎确定性的行为:

<start> <start> -> <start> Hello : 1.0

<start> Hello -> Hello World. : 1.0

Hello World. -> World. Hello : 0.5
Hello World. -> World. <end> : 0.5

World. Hello -> Hello Dolly. : 1.0

Hello Dolly. -> Dolly. Hello : 1.0

Dolly. Hello -> Hello World. : 1.0

You use a random number generator to pick which path you go down. You have to save each state (which is really a history of N previous items) and the probabilities for that state. Then you pick a random number and decide based on it what the next state you transition to is.

In your example you have a Markov chain with an N of 1 you would have a chain structure that looked something like this:

<start> -> Hello : 1.0

Hello -> World. : 0.66666
Hello -> Dolly. : 0.33333

Dolly. -> Hello : 1.0

World. -> <end> : 0.5
World. -> Hello : 0.5

If your current state is Hello, then your next possible states are World. and Dolly.. Generate a random number between 0 and 1 and choose World. if it's less than 0.666666, otherwise choose Dolly.

With an N=2 Markov chain, you get almost deterministic behavior with that input:

<start> <start> -> <start> Hello : 1.0

<start> Hello -> Hello World. : 1.0

Hello World. -> World. Hello : 0.5
Hello World. -> World. <end> : 0.5

World. Hello -> Hello Dolly. : 1.0

Hello Dolly. -> Dolly. Hello : 1.0

Dolly. Hello -> Hello World. : 1.0
悸初 2024-08-11 02:54:38

两个评论:

1)要从随机过程中生成样本,无论某个选择的可能性是否很大(> 50%),而其他选择的可能性较小,只需要加权“硬币翻转”:均匀地生成随机实数[0,1),并以相同的固定顺序考虑可能性,保持到目前为止的概率总和。一旦该总和超过您随机选择的数字,请选择该选项。如果您的选择具有非标准化(总和不为 1)概率,您首先需要计算概率 s 的总和,然后将它们全部除以 s,或者在 [0,s) 上选择随机数

2) 为了防止估计时过度拟合您的模型来自少量样本训练数据(与参数数量相比),对模型参数使用贝叶斯先验。对于一个非常酷的示例,其中模型参数的数量(历史大小)未预先固定为任何有限数量,请参阅 无限 HMM。如果您不使用贝叶斯方法,那么您将需要根据您拥有的训练数据量适当选择历史长度,和/或实现一些临时平滑(例如,2 阶和 2 阶之间的线性插值) 1 个型号)。

Two comments:

1) To generate samples from a random process, whether or not a certain choice is quite (>50%) likely, and others less so, just requires a weighted "coin flip": generate a random real number uniformly on [0,1), and consider the possibilities in the same fixed order, keeping a sum of probabilities so far. As soon as that sum exceeds your randomly chosen number, select that choice. If your choices have unnormalized (not summing to 1) probabilities, you first need to compute the sum of probabilities s, and either divide them all by s, or choose your random number on [0,s)

2) To prevent overfitting when estimating your model from a small amount of sample training data (compared to the number of parameters), use Bayesian priors on the model parameters. For a really cool example of this, where the number of model parameters (history size) isn't fixed to any finite number in advance, see the Infinite HMM. If you don't use Bayesian methods, then you'll want to choose the history length appropriately for the amount of training data you have, and/or implement some ad-hoc smoothing (e.g. linear interpolation between an order-2 and order-1 model).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文