# DDTMS: Dirichlet-Distribution-Based Trust Management Scheme in Internet of Things
## 3 Dirichlet-Distribution-Based Trust Management Scheme (DDTMS)
### Dirichlet-Based Reputation Distribution Model  
#### 3.2.1 Dirichlet Distribution  
The binomial distribution is the probability distribution of the number of positive occurrences in an independent repeated \(n\)-time Bernoulli experiment.The polynomial distribution, as an extension of the binomial distribution, describes the joint probability distribution of the number of occurrences of each variable.We suppose \(X=(x_{1},x_{2},\ldots x_{n})\), where, \(x_{i}\) represents the probability that the experimental result is the \(i\)-th type, and \(x_{i}\in\{0,1\}\). The variable \(i\) represents the \(n\) types that may occur, namely, \(i=~{}1,~{}2,~{}3,~{}\ldots,~{}n\). So the probability distribution for \(x\) is  
\[p(x|\mu)=\prod_{i=1}^{n}\mu_{i}^{x_{i}} \tag{1}\]  
Figure 1: Flow chart for DDTMS design.  
where, \(\mu=(\mu_{1},\mu_{2},\mu_{3},\ldots,\mu_{n})\) and \(\sum\limits_{i=1}^{n}\mu_{i}=1\). If we repeat \(N\) observation experiments, then \(\sum\limits_{i=1}^{n}x_{i}=N\). Since the Dirichlet distribution and the polynomial distribution belong to the same conjugate distribution family, the conjugate prior to the polynomial distribution has the following expression  
\[p(\mu|\alpha)\propto\prod\limits_{i=1}^{n}\mu_{i}^{\alpha_{i}-1} \tag{2}\]  
Therefore, we normalize the above formula, and the probability density function of the Dirichlet distribution is  
\[Dirichlet(\mu|\alpha)=\frac{1}{B(\alpha)}\prod\limits_{i=1}^{n}\mu_{i}^{ \alpha_{i}-1} \tag{3}\]  
Based on the observation sequence of n-type output and its corresponding output value, the Dirichlet distribution represents the a priori physical count of n variables. \(B(a)\) is a polynomial extension of the Beta function, and the form that is normalized as constant is  
\[B(\alpha)= \frac{\prod\limits_{i=1}^{n}\Gamma(\alpha_{i})}{\Gamma(\sum\limits_ {i=1}^{n}\alpha_{i})} \tag{4}\]  
We use the prior distribution and posterior parameter \(y_{i}+\alpha_{i}\), the posterior distribution of Dirichlet can be obtained as  
\[Dirichlet(\mu|y+\alpha)=\frac{1}{B(y+\alpha)}\prod\limits_{i=1}^{n}\mu_{i}^{ y_{i}+\alpha_{i}-1} \tag{5}\]  
When all categories are at the beginning of the event, namely, there is no any physical count of a priori observation, we set \(\alpha_{i}=1\ (1\leq i\leq n)\), then the expected value for each probability \(\mu_{i}\) in the Dirichlet distribution is  
\[E(\mu_{i})=\frac{\alpha_{i}}{\sum\limits_{j=1}^{n}\alpha_{j}} \tag{6}\]  
The above equation expresses the relative probability of occurrence of a certain type \(i\) event, and expects are taken as the occurrence probability of these events in the next interaction. Therefore, when the observedvalue of the next round of experiment is \(x\), the Equation (3) can be rewritten \(Dirichlet(\mu|x+1)\) to indicate the posterior distribution of the above-mentioned a prior observation event, and then the corresponding expected value is  
\[E(\mu_{i})=\frac{x_{i}+1}{n+\sum\limits_{j=1}^{n}\alpha_{j}} \tag{7}\]  
Generally, in a Beta-based model, events are divided into two categories for processing. However, in many cases, this is far from meeting the requirements of complex application scenarios. By contrast, the use of Dirichlet distribution to describe the reputation distribution of nodes in IoT through interactive behavior is often more practical. This is because the question is whether the interaction between two nodes is successful or notis transformed into a process in which a normal node interacts with multiple different types of malicious nodes. This process can use the Dirichlet distribution model to simulate the relevant reputation distribution, and eventually, to detect or defend against many different types of attacks by using trust values.