# A Novel Approach for Software Defect prediction Based on the Power Law Function
## 2 Fundamental Characteristics of Power Law Function and Software Defects
### Power Law Function Curvature  
Before using power law distribution function to predict software defects, the concept of curvature should be introduced. Curvature refers to the bending degree of a curve [38]. It can be described by the ratio of the angle changed by the curve to the radian changed by the curve. Figure 2 presents a sketch map of power law function curvature. Let \(M\) and \(M^{\prime}\) be the two points on the curve. If the tangent of the curve at point \(M\) and point \(M^{\prime}\) and the positive intersection angle of the \(x\)-axis are respectively \(\alpha\) and \(\alpha+\Delta\alpha\). Therefore, when the point changes from \(M\) along the curve to \(M^{\prime}\), the angle changes \(\Delta\alpha\), and the distance to change this angle is the arc length \(\Delta s=\widehat{M}\widehat{M^{\prime}}\). Therefore, curvature is defined by a differential equation to indicate the degree the curve deviates from the straight line. The greater the curvature, the greater the curve's bending degree and deviation from the straight line. Expression of curvature at point \(M\) can be stated as follows. \[K=\lim_{\Delta s\to 0}\left|\frac{\Delta\alpha}{\Delta s}\right|. \tag{2}\]  
where \(\Delta s\) tends to zero. The reciprocal of curvature is curve radius, with a larger curve radius yielding a smoother arc. The angle and arc length approaching zero at the same time is the standard curvature definition of a smooth curve with an arbitrary shape. Obviously, when \(M^{\prime}\) and \(M\) are close enough, the arc length \(\Delta s=\widehat{M}\widehat{M^{\prime}}\) can be approximately replaced by the chord length \(M\)\(M^{\prime}\), and  
\[\lim_{M^{\prime}\to M}\widehat{M}\widehat{M^{\prime}}=1. \tag{3}\]  
Therefore, in:  
\[\frac{\Delta s}{\Delta x}=\frac{\widehat{M}\widehat{M^{\prime}}}{\Delta x}= \frac{\widehat{M}\widehat{M^{\prime}}}{M\widehat{M^{\prime}}}\frac{M\widehat{ M^{\prime}}}{\Delta x}=\frac{\widehat{M}\widehat{M}^{\prime}}{M\widehat{M^{ \prime}}}\frac{\sqrt{\left(\Delta x\right)^{2}+\left(\Delta y\right)^{2}}}{ \Delta x}=\frac{\widehat{M}\widehat{M}^{\prime}}{M\widehat{M^{\prime}}}\sqrt {1+\left(\frac{\Delta y}{\Delta x}\right)^{2}} \tag{4}\]  
Figure 2: Power law function curvature. Let \(\Delta x\to 0\), the following expression can be obtained by taking the limit:  
\[ds=\sqrt{1+{y^{\prime}}^{2}}dx \tag{5}\]  
Let the curve equation be \(y=f(x)\). Because \(tg\alpha=y^{\prime}\), so \(\alpha=arctgy^{\prime}\), making differential calculation on \(\alpha=arctgy^{\prime}\), we will get:  
\[d\alpha=(arctgy^{\prime})^{\prime}dx=\frac{y^{\prime\prime}}{1+{y^{\prime}}^{ 2}}dx \tag{6}\]  
Therefore, the curvature of a curve can thus be expressed as follows. \[k(x)=\left|\frac{d\alpha}{ds}\right|=\frac{\left|y^{\prime\prime}\right|}{ \left(1+{y^{\prime}}^{2}\right)^{\frac{3}{2}}} \tag{7}\]  
If the metrics power law function is expressed as \(m(x)=\alpha x^{-\gamma}\), then:  
The first-order derivative of \(m(x)\) is \(m^{\prime}(x)=-\alpha\gamma x^{-(\gamma+1)}\);  
The second-order derivative of \(m(x)\) is \(m^{\prime\prime}(x)=\alpha\gamma(\gamma+1)x^{-(\gamma+2)}\);  
By finding the first and second derivatives of \(m(x)\) and substituting them into Equation (3), the curvature function corresponding to \(m(x)\) can be obtained as follows. \[k(x)=\frac{m^{\prime\prime}(x)}{\left[1+m^{\prime 2}(x)\right]^{\frac{3}{2}}}= \frac{\alpha\gamma(\gamma+1)x^{-(\gamma+2)}}{\left[1+\alpha^{2}\gamma^{2}x^{- 2(\gamma+1)}\right]^{\frac{3}{3}}} \tag{8}\]  
As shown in Figure 2, the closer the curve is to the Y axis, the smaller its curvature is, and when the curve is further away from the Y axis, it becomes increasingly curved and thus its curvature increases. At a certain point, the curve begins to essentially parallel to the X axis and the curvature then decreases. This indicates that the power law function curve's curvature goes from small to large and then from large to small. Thus, a maximum curvature point exists, which may be the transformation point of the metrics from defective to defect-free.