How to check how unique your NFT collection really is
Tags: nft, collection, probability, unique
Published: 2022-01-12 20:58:35

An NFT collection consists of many items, each of which every item is unique, or at least should be unique. If you create what is called an avatar collection, where an item is created by layering, you often end up with a largely unique collection. We can even find a formal model for this.

Let us say we have `x` layers (i.e. background, face, glasses, mouth, nose, ...). Each layer can have `y` different states (e.g. yellow background, green background, white background, ...). If the layers have a different number of states, you can use the average number of states, which is a sufficient approximation. We can then find the number of possible combinations by `x^y (Math.pow(x, y)`. Suppose we have 5 layers, where each layer can have 10 different states, then we get `10^5 = 100000` different combinations. 

So what is the probability that we have a duplicate NFT in 10000 generated objects (i.e. two objects that have the same state in each layer)? Again, we apply mathematics to this problem. Basically, we draw from a pool of `x^y` combinations with repetitions. On the first try, we have no chance of getting a duplicate, since we only drew once. After that, we still have `x^y` combinations to draw from, but we only consider the combinations that are not identical, so `x^y-1`. The next time we draw again from `x^y` combinations with `x^y-2` valid combinations. I think you can see the pattern now. If we multiply these values, we get the chance of `n` drawings, each of which is unique. We need to invert this because we want to get the chance that we have at least one duplicate in our randomly generated NFT collection.

Let us write a small javascript program where we can enter our numbers.

```
const calculateUniqueness = (count, poolSize) => {
    let result = poolSize / poolSize;
    
    for (let i = 1; i < count; i++) {
        result = result * (poolSize - i) / poolSize;
    }

    return 1 - result;
};

console.log("Chance of duplicates", calculateUniqueness(10000, 100000));
```

The output of this program (5 layers, 10 different states each, 10000 generated NFTs) is **1**. You have a 100% probability of having at least one duplicate. That's scary, considering that 5 layers with 10 different states is quite a lot! But with this formula, we immediately know what to do about it. Let's us put in some numbers.

Suppose we still have 5 levels now, but with 20 different combinations. The pool size is now 3200000 and the probability of duplicates is 99.99%. This is still not good, even if we now have now 20 different states for our layers, which is a huge amount of assets to create (100 assets)!

In our second scenario, we now have 8 layers with 10 different states. The pool size is now 100000000 and the probability of duplicates is 39.34%, which is a huge improvement. If we increase the number of layers to 10, the probability of duplicates is 0.49%, which is almost non-existent. Note that we still only have 100 assets to create, which is the same number as in our first scenario. So if you want more uniqueness in your NFT collection, you should increase the number of layers over the number of states each layer can have.

Since we are dealing with probabilities, you can still get a unique collection even if the probability of duplicates is high. Therefore, you should analyze your collection with property profiles. We will cover this in the next article.

EDIT: I also created a website for this, where you can plugin your numbers as well. You can access this tool [here](https://nft-uniqueness-checker.vercel.app/). Feel free to leave feedback!