How would you approach designing an algorithm to detect anomalous transaction patterns without relying on machine learning libraries?