Domain-to-range ratio
This article's tone or style may not reflect the encyclopedic tone used on Wikipedia. (May 2016) |
The domain-to-range ratio (DRR) is a ratio which describes how the number of outputs corresponds to the number of inputs of a given logical function or software component. The domain-to-range ratio is a mathematical ratio of cardinality between the set of the function's possible inputs (the domain) and the set of possible outputs (the range).[1][2] For a function defined on a domain, , and a range, , the domain-to-range ratio is given as:
Example[edit]
Consider the function isEven()
below, which checks the parity of an unsigned short number , any value between and , and yields a boolean value which corresponds to whether is even or odd. This solution takes advantage of the fact that integer division in programming typically rounds towards zero.
bool isEven(unsigned short x) {
return (x / 2) == ((x + 3)/2 - 1);
}
Because can be any value from to , the function's domain has a cardinality of . The function yields , if is even, or , if is odd. This is expressed as the range , which has a cardinality of . Therefore, the domain-to-range ratio of isEven()
is given by:
See also[edit]
References[edit]
- ^ Voas, J.M.; Miller, K.W. (March 1993). "Semantic metrics for software testability". Journal of Systems and Software. 20 (3): 207–216. doi:10.1016/0164-1212(93)90064-5.
- ^ Woodward, Martin R.; Al-Khanjari, Zuhoor A. (5 September 2000). Testability, fault size and the domain-to-range ratio: An eternal triangle. ACM SIGSOFT. pp. 168–172. doi:10.1145/347324.349016. ISBN 978-1-58113-266-3. S2CID 17772461.
- ^ Tarlinder, Alexander. Developer testing : building quality into software. ISBN 0-13-429106-9. OCLC 992888632.