C# automatic development of one machine one code encryption

1. C# generate private key and public key
2. Obtain and install host PC motherboard, hard disk, CPU information for encryption
3. Use public key to encrypt machine combination information to obtain product registration KEY
4. Use private key to decrypt the registration KEY to enter the system

File: n459.com/file/25127180-479634136 Access password: 551685

There is a classic problem in the textbook of probability theory, which has been bothering me for a long time. Many times I thought I wanted to understand, but after a while, I became confused again. Students who have studied probability theory must know this problem, which is the famous three-door problem.
It is said that there was a famous variety show in the United States before, and there were three closed doors in this show. Two of them have goats behind them, and one has a luxury car. The host will let the guest make a choice. After the guest makes a choice, the host will open one of the wrong doors and ask the guest: Man, do you have a chance to change your choice, do you want to use it?

We will not talk about the effects of the show, but the math behind it is very interesting. We change or do not change the choice, how big are the wins?

We analyze it from intuition, and it shouldn’t be affected if we don’t change the answer. After all, there is a correct answer in the three doors, and the host excluded the wrong answer, which means that the correct answer lies in the remaining two doors. Regardless of whether we change or not, the probability of the jackpot behind the door should be one-half. But the answer in the book is that if you don't replace it, the probability of winning is one-third, and if you replace it, the probability of winning is as high as two-thirds.

This answer is obviously contrary to our intuition, so it is necessary for us to explore the underlying mathematical principles. In fact, this is also a very important example in probability theory to understand conditional probability and Bayesian formula.

Conditional Probability

Conditional probability is not unfamiliar to everyone, we learned it in math class very early.

To review briefly, suppose there are two events A and B in the sample space. If there is no correlation between the two events A and B, then they are considered independent events. For example, if I drank milk this morning as incident A, my article forwarded more than 10 as incident B. Obviously these two events are not related in any way. Whether I drink milk or not will not affect the amount of forwarding of the article. Then it is said that these two events are independent events:

Of course, there are also cases where two events are related to each other. For example, if I drink milk in the morning and whether I am late for work is likely to be a related event. Because it takes time to drink milk in the morning, it is likely to affect whether you are late. At this time, P(AB) is related to the two events, not just a simple product.

As shown in the figure above, when the two events AB are not independent events. P(AB) refers to the intersection of the two events of AB, which can be regarded as the occurrence of event A under the premise of event B, or the occurrence of event B under the premise of event A.

In probability theory, the probability of another event occurring under the premise that something happens is called conditional probability, written as P(B|A).

We write the previous conclusion as a formula:

The derivation of this formula is very natural, but it is very useful. Because conditional probability is not intuitive in many cases, we need to use this formula to calculate it.

Let's look at a classic example in a book to consolidate it.

Assuming two cities AB, the probability of rain in city A is 20%, the probability of rain in city B is 18%, and the probability of rain in both places is 12%. What is the probability that it rains in B and also rain in A .

This question is very simple, we can apply the formula directly, obviously

Then:

Total probability formula

When we introduce conditional probability, we use two events A and B to talk about things. But there are more than two related events in real life. If multiple events are related to event A, what should the formula be like at this time?

We put all events related to event A into a group, called group B, which contains n events. Then according to the previous conditional probability, we can use event B to represent event A.

This formula is called the total probability formula. The premise of this formula is that the B event group is the set of all events related to the A event, also known as the complete event group.

Bayes Theorem

This is also the highlight of this article. There is only a simple formula for Bayes' theorem in the textbook:

In fact, it is the formula we derived above based on the conditional probability. Of course it’s good to understand it this way, but it can only understand a very shallow level of meaning. If you only understand this level, the latter a priori, posterior probability, and maximum likelihood are difficult to understand.

Let's move on to the next level of understanding. This time, we deform the total probability formula:

Then, the conditional probability of occurrence of event A and event Bi is:

This formula looks ugly, but it actually illustrates the connection between the result and the cause. For a very simple example, suppose the A event is a car alarm. Then there are many reasons for incident A, such as accidental collision of pedestrians, car thief to steal, or alarm failure. The set of these causes of occurrence of A is the B event group.

If we hear the alarm one night, what we have to do is actually guess the cause of event A based on event A, which is to calculate P(Bi | A).

Because it is at night, the probability of pedestrian collision is very low, so the high probability is because of car thieves. At this time, we need to get up to check. If it is daytime, on the contrary, the probability of pedestrian collision is high, and the possibility of car thief committing crime is very small, so we can ignore it.

In other words, event A is an event that we can directly observe, while event B is the reason behind the event. The Bayesian formula is a tool for finding the cause of effect. This is the real greatness of Bayes' theorem.

In statistics, the probability of an event that can be directly observed is usually called a priori probability, which means that we can directly measure the probability through experiments. The reason behind this probability is called the posterior probability, which means that we need to calculate the probability through the prior probability. Maximum likelihood estimation is to calculate the parameters that maximize the probability of occurrence based on the function of the posterior probability.

Finally, let's go back to the example from the beginning and try to calculate the result using Bayes' theorem.

We use 1, 2, and 3 to represent the three doors respectively. Obviously, luxury cars may appear behind any of them. In order to simplify the expression, we assume that the guest must choose the first door to open, and the host opens the second door.

We define four events ABCD, three events ABC represent luxury cars behind three doors, and event D represents the probability of the host opening the second door.

Intuitively we feel

But we are not sure. It doesn't matter, we can figure it out.

First of all:

This is also easy to see. Because if the prize appears behind the second door, the host will never open the second door, so P(D|B)=0. Similarly, if the prize is behind the third door, the host must open the second door. So P(D|C)=1.

Substituting in, it can be calculated:

Next, we have to calculate P(A|D) and P(C|D).

According to Bayes' theorem:

Through various calculations, we finally got the correct result. But even if we understand the Bayesian principle and understand these calculation processes, we still cannot answer the doubts in our hearts. Why is this different from our intuitive feelings? Why is the answer not 1 /2?

This question is actually very simple, because our thinking is limited. We only focused on the remaining two doors that were not opened, completely ignoring the impact of the opened doors.

Suppose we change the game, still three doors, still a prize, or randomly placed. Suppose someone can choose one or two doors at a time. So what is the probability of winning these two options? Obviously, the probability of choosing two doors is of course 2/3. At this time, we must open the wrong one of the two doors. Will the result change? Of course not.

Similarly, when the host asks whether to change the choice, it is actually asking whether we want to choose one door or two doors. If we don’t change our choice, we just choose a door. And if we change our choice, it is actually equivalent to choosing two doors at the beginning. There must be a wrong answer among the two doors, and excluding it will not affect the final result.

Before the host opens that door, the probabilities of the three are equal. When the door was opened, we all knew that the probability of that door collapsed and collapsed to zero. The reduced probability of it is actually not evenly divided among the remaining two doors. Understand this, this problem will be easily solved.

Guess you like

Origin blog.csdn.net/gumenghua_com1/article/details/112826268