# A Novel Approach for Software Defect prediction Based on the Power Law Function
## 2 Fundamental Characteristics of Power Law Function and Software Defects  
### Correlation and Characteristics  
Various power law phenomena can be observed in nature and society, and the study of these phenomena has continued for more than a century. Even now, the power law phenomenon is still a research hotspot in many disciplines. Harvard University linguistics expert [PERSON] studied the frequency of English words and found a simple inverse relationship between each word's frequency and the constant power of its rank in order from large to small. This distribution, known as [PERSON]'s law, shows that only a few words in English are frequently used and that most words are seldom used [21]. Italian economist [PERSON] studied the statistical distribution of personal income and found that the income of a few people was much higher than that of the majority. Thus, he put forward the famous 80/20 rule, commonly known as [PERSON]'s law, in which 20% of the population occupied 80% of the social wealth [22]. [PERSON]'s law and [PERSON]'s law are simple power law function patterns. In fact, power law distribution exists in many fields, such as physics, earth and planetary science, computer science, biology, ecology, demography and social science, and economy and finance, and has various manifestations [23; 24; 25; 26; 27; 28; 29; 30; 31].  
Furthermore, [PERSON] and [PERSON] [32] validated the effects power laws have on software metrics interpretations and found that many metrics demonstrate a power law behavior. Furthermore, threshold values with respect to instances were derived from power law function properties. Additionally, [PERSON] and [PERSON] [33] found that a power law implied that smaller values were commonplace, whereas larger values were extremely rare. Meanwhile, [PERSON] and [PERSON] [34] quantitatively analyzed distributions of defects in three different projects and determined through graphical analysis that a small number of instances (20%) were correlated with 63%-70% of prerelease defects.  
The general formula of the power law function can be written as:  
\[y=cx^{-\gamma}. \tag{1}\]  
where \(c\) and \(\gamma\) are both constants greater than zero.  
Logarithms of both sides in Equation (1), \(\ln y\) and \(\ln x\), satisfy a linear relationship. In other words, in the double logarithmic coordinates, the power law function represents a straight line with a negative slope of the power exponent. This linear relationship is the basis for judging whether the random variable in each instance satisfies the power law function [35].  
The power law is also a sign of transitioning from steady to chaotic states in the chaotic edge of self-organized critical systems [36]. The power law can be used to predict phases and phase transitions for such systems. Most software defect data have unbalanced distribution characteristics [37], i.e., defect-free instances are more common than defective instances. Many software system defects are concentrated in a small part of the instances, which is characteristic of a power law function.  
Figure 1 shows the distributions of the NOC (number of children of a given class in an inheritance tree) and RFC (number of distinct methods invoked by code in a given class) metrics from an example using the Camell1.6 dataset in the Promise database.  
Figure 1: Distributions of metrics values of number of children of a given class in an inheritance tree (NOC) and number of distinct methods invoked by code in a given class (RFC) in the Camell1.6 dataset.  
As seen in Figure 1, metrics values are distributed in the form of a power law function, which has also been validated by [PERSON] [21]. Therefore, there is a close correlation between the power law function and software system metrics.