Bayesian decision-making instance

Source: Internet
Author: User

[This article introduces the Bayesian formula]

Here is an example to illustrate how to use Bayesian formulas for decision making.

Example:

Suppose there are 100 people, and everyone has their own birthdays. One year has 12 months. Assume thatBirthdayThe distribution of people from January to December is as follows:

3 4 5 7 10 13 14 15 12 8 5 4

The ratio of people born in January to December is as follows:

0.0300 0.0400 0.0500 0.0700 0.1000 0.1300 0.1400 0.1500 0.1200 0.0800 0.0500 0.0400

Put the data in MATLAB:

It is more intuitive to draw with MATLAB:

This rate1 ArrayIs the probability density function.It meets two conditions: greater than 0 and integral is 1 (because sum (rate1) = 1, see the MATLAB command line ).

Now, let us assume that the first 100 people are samples from the northern hemisphere. Now we will collect the birthdays of 100 people in the Southern Hemisphere as samples.

The distribution of people born from to is:

15 12 9 6 4 3 4 5 7 9 12 14

The ratio of people born in January to December is as follows:

0.1500 0.1200 0.0900 0.0600 0.0400 0.0300 0.0400 0.0500 0.0700 0.0900 0.1200 0.1400

Sum

Draw the following curve:

Obviously, the rate2 curve can be used as the probability density function of the southern hemisphere data, because rate2 (x)> 0 and sum (rate2) = 1.

Combine the birthday Probability Density Curve of people in the southern hemisphere with the probability density distribution curve of people in the northern hemisphere.

(This example is a bit extreme. It's good to explain the problem ...... Orz)

Assume that an event is ω 1 for the people of the Northern Hemisphere and ω 2 for the people of the southern hemisphere. Obviously, a person on earth is either in the southern hemisphere or in the Northern Hemisphere, so P (ω 1) + P (ω 2) = 1

Now let's look at the ratio of people in the southern hemisphere to people in the northern hemisphere? Google

Ignore unnecessary information and we can get P (ω 1)/P (ω 2) = 9

That is to say, P (ω 1) = 0.9, P (ω 2) = 0.1

Therefore, our example can be abstracted:

The feature value is "Birthday" and "Birthday = x.

P (X|ω 1) = rate1(Red Curve),P (X|ω 2) = rate2(Blue Curve)

(The origins of the red and blue curves have been introduced)

And the prior probability P (ω 1) = 0.9, P (ω 2) = 0.1

Now, the denominator of the Bayesian formula is required, that is, the evidence factor.

According to Formula

ZhiP (x) =P (x | ω 1) P (ω 1) + p (x | ω 2) P (ω 2)

Now, if we meet a friend on Google +He knows his birthday is July June.So how can we guess whether this friend is from the southern hemisphere or the northern hemisphere ??

The Bayesian formula is on !!

We already know the parameters on the right of the formula. Now we can calculate the number on the left.

The birthday is January 1, June, that is, x = 6.

ThereforeP (ω 1 | X), P(ω 2 | X)AndP (x)Can be obtained, respectively

P (x | ω 1) = Rate1 (6) = 0.1300

P (x | ω 2) = Rate2 (6) = 0.0300.

P (x)= P (x | ω 1) P (ω 1) + p (x | ω 2) P (ω 2) = 0.13*0.9 + 0.03*0.1 = 0.12

∴ P (ω 1 | X) =P (x | Omega 1) P (ω 1)/P (x) = 0.13*0.9/0.12= 0.975

P (ω 2 | X) =P (x | ω 2) P (ω 2)/P (x) = 0.03*0.1/0.12= 0.0250

So this mysterious friend97.5% of the probability is from the northern hemisphere, and only 2.5% of the probability is from the southern hemisphere..

We can set such a decision rule:

"IfP (ω 1 | X)>P (ω 2 | X), The decision isω 1Class. Otherwiseω 2Class"

That is to say, if we "boldly assume" this friend is from the northern hemisphere, then we guessError ProbabilityYes

P (error | X) = min [P (ω 1 | X), P (ω 2 | X)] = 0.025

-----------------------------------------------------

Postscript:


From the above example, we can see that the evidence factor p (x) is not important in making a decision. It is just a scalar used to represent a proportion, that is, the occurrence frequency of the pattern with feature value x that we actually measure. If you remove it, you can also change the decision rule

"If p (x | ω 1) P (ω 1)> P (x | ω 2) P (ω 2), it is determined to be ω 1; otherwise, it is ω 2."

The general idea of using Bayesian formulas to help make decisions is to calculate the possibility that a sample to be tested with a feature value of X belongs to different categories, and then select the highest probability (that is, the highest possibility) based on the decision rules) as the result of the decision.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.