Implement Rand index