Ok, this is a stats question:
Say you have 1 trading card out of a total of 10,000.
Each trading card has a random number of traits, such as:
Background, Holographic, Type, Special Power, Accessories.
Each card can have a random number of attributes, so one card may only have Background: Red while one might have Background: Blue, Holographic: true, Type: Grass
If you know the total list of traits, in this case, 5 total traits. Each trait has X number of possiblities, such as:
Background:
red, blue, orange, green, etc.....
You also know, that Background: Red has a rarity value of 0.9%, meaning of all background traits, only 0.9% of them have a red background.
Meaning you also know the total number of traits which is total_trait_count x total_trait_possiblities and then you know there are only 10,000 total cards.
How would you find what the total rarity is of one card specifically?
To give an example, a card that has one trait, would be extremely rare, as on average, most cards have 3-5 traits.
But a card with 5 traits, and all traits have a rarity of 0.005% would also be extremely rare.
So what formula can you use to figure out the rarity of a single card, based off this data?
Here is an example data we have of traits: (note: we have all the total possible traits that could exist, this is just a small sample to show the format)
Background::Aquamarine:
rarity: 12.635620096811884
weight: 0.8736437990318812
Background::Army Green:
rarity: 12.452011350358871
weight: 0.8754798864964113
Background::Blue:
rarity: 12.585544984142881
weight: 0.8741445501585712
Background::Gray:
rarity: 11.467200801201804
weight: 0.885327991987982
Background::New Punk Blue: {rarity: 11.884493406776832, weight: 0.8811550659322317}
Background::Orange: {rarity: 12.568853279919882, weight: 0.8743114672008012}
Background::Purple: {rarity: 13.186446336170924, weight: 0.8681355366382908}
Background::Yellow: {rarity: 13.219829744616925, weight: 0.8678017025538307}
Clothes::Admirals Coat: {rarity: 0.6780357509759606, weight: 0.9932196424902404}
Clothes::Bandolier: {rarity: 2.034107252927882, weight: 0.9796589274707211}
Clothes::Bayc T Black: {rarity: 2.5066776248202176, weight: 0.9749332237517978}
Clothes::Bayc T Red: {rarity: 1.7875487980275324, weight: 0.9821245120197247}
Clothes::Biker Vest: {rarity: 3.410725292788165, weight: 0.9658927470721184}
Clothes::Black Holes T: {rarity: 2.5272241627285803, weight: 0.9747277583727142}
Clothes::Black Suit: {rarity: 0.5958495993425108, weight: 0.9940415040065749}
Clothes::Black T: {rarity: 3.410725292788165, weight: 0.9658927470721184}
Clothes::Blue Dress: {rarity: 1.2944318882268337, weight: 0.9870556811177317}
Clothes::Bone Necklace: {rarity: 2.5683172385453052, weight: 0.974316827614547}
Clothes::Bone Tee: {rarity: 2.5066776248202176, weight: 0.9749332237517978}
And the card itself has these traits:
0: {trait_type: 'Clothes', value: 'Bandolier', p: 2.034107252927882}
1: {trait_type: 'Mouth', value: 'Discomfort', p: 2.0363879152061424}
2: {trait_type: 'Eyes', value: 'Heart', p: 3.972625605074278}
3: {trait_type: 'Hat', value: 'Cowboy Hat', p: 4.73831574413095}
4: {trait_type: 'Background', value: 'Blue', p: 12.585544984142881}
5: {trait_type: 'Fur', value: 'Dark Brown', p: 13.470205307961944}
In this situation, there are a total of 5599 cards that have the same number of attributes as this one. Meaning, roughly 50% of the cards have 6 attributes.
Whereas, there are some cards with only 3 traits total, and only 3 total cards out of 10,000 have 3 traits. Therefore if the card has 3 traits, it would be automatically one of the most rare cards.
Where p is supposed to be the rarity of the trait, but for this example, you can remove it, since I don't think its properly calculated.
Using the data above, a card with only 1 trait should be the rarest of all cards, if its one single trait is a rarity of say 12%, it would not be the rarest using our current calculation, even though it should, so our formula is incorrect.
The final format for rarity should be what percentile this card is out of all of the cards. So is this card in the top 1% of all 10,000 cards (insanely rare)? Or top 5% (rare)? or top 50% (common card)?
How would you derive a formula to calculate the percentile score of a card out of its 10,000 other cards.
The goal here is to say - your card has a 1 out of 1,000,000 chance of occurring, therefore its super rare. Or your card is 1 out 50 chance of occurring, therefore its common.
In the following answer, I made the heavy simplification that for cards, in general, the distribution of the various traits are independent of each other.
For example, in the example given in the Addendum, I assumed that the Background of Red (probability = $0.3$) is unaffected by whether the card features No Hat, or a Fedora.
Attempting to diagnose which traits are not independent of each other, and how that affects the rarity of a card would significantly complicate this (already) long-winded answer.
Suppose that there are $n$ total traits, $t_1, t_2, \cdots, t_n$.
Examine a specific trait, $t_i$.
Suppose that this trait may take on $a_i$ values,
that I will denote as $v_{(i,1)}, v_{(i,2)}, \cdots, v_{(i,a_i)}.$
It is assumed that $v_{(i,1)}$ will always represent the situation where the trait $t_i$ is missing from the card.
For each of the values $v_{(i,1)}, v_{(i,2)}, \cdots, v_{(i,a_i)},$
let the probability of a card having the specific value for trait $t_i$ be represented by
$p_{(i,1)}, p_{(i,2)}, \cdots, p_{(i,a_i)}$ respectively.
It is presumed that for any $i \in \{1,2,\cdots, n\}$
each of $p_{(i,1)}, p_{(i,2)}, \cdots, p_{(i,a_i)}$ is non-negative
and that $p_{(i,1)} + p_{(i,2)} + \cdots + p_{(i,a_i)} = 1.$
To clarify, each trait variable $v_{(i,j)}$ and its corresponding probability variable $p_{(i,j)}$ have two indices. The first index determines which trait $t_i$ the variable is associated with. The second index determines which possible value, associated with that trait, pertains to this variable.
Now, a framework has been constructed to respond to the original poster's question.
Suppose that for a specific card, for each trait, $t_i$, the card has the specific value $v_{(i,b_i)}$,
where $b_i$ represents one of the indices in $\{1,2,\cdots,a_i\}.$
Then, the rarity of that card is represented by
$$\prod_{i=1}^n p_{(i,b_i)}.$$
Addendum
Responding to the comment/question of Zach.
I will provide an example similar to the examples suggested in your question.
Let $n = 3$, with traits $t_1, t_2, \cdots, t_3$ that pertain to the traits of
Background, Clothes, Hat, respectively.
That is, $t_1$ pertains to the trait of Background
and $t_3$ pertains to the trait of Hat.
Assume that the for the trait $t_1$, Background,
there are 5 possible values.
So, $a_1 = 5$, and these values are represented by the variables
$v_{(1,1)}, v_{(1,2)}, v_{(1,3)}, v_{(1,4)}, v_{(1,5)}$.
Here, assume that with respect to trait $t_1$, Background,
the $5$ value variables, $v_{(1,1)}, \cdots, v_{(1,5)}$ represent the traits of
No Background, Red, Blue, Orange, and Green, respectively.
Assume that the chance of a card having each of these traits is given by
$p_{(1,1)} = 0, p_{(1,2)} = 0.3, p_{(1,3)} = 0.2, p_{(1,4)} = 0.2,p_{(1,5)} = 0.3.$
This means that (for example) the probabilility of a card having No Background is $0$, while the probability of a card having the Background of Green is $0.3$.
Continuing this example, assume that the for the trait $t_2$, Clothes,
there are 3 possible values.
So, $a_2 = 3$, and these values are represented by the variables
$v_{(2,1)}, v_{(2,2)}, v_{(2,3)}$.
Here, assume that with respect to trait $t_2$, Clothes,
the $3$ value variables, $v_{(2,1)}, \cdots, v_{(2,3)}$ represent the traits of
No Clothes, Tuxedo, Shirt+Pants, respectively.
Assume that the chance of a card having each of these traits is given by
$p_{(2,1)} = 0, p_{(2,2)} = 0.6, p_{(2,3)} = 0.4.$
This means that (for example) the probabilility of a card having No Clothes is $0$, while the probability of a card having the Clothing of Shirt+Pants is $0.4$.
Continuing this example, assume that the for the trait $t_3$, Hat,
there are 4 possible values.
So, $a_3 = 4$, and these values are represented by the variables
$v_{(3,1)}, v_{(3,2)}, v_{(3,3)}, v_{(3,4)}$.
Here, assume that with respect to trait $t_3$, Hat,
the $4$ value variables, $v_{(3,1)}, \cdots, v_{(3,4)}$ represent the traits of
No Hat, Cowboy Hat, Fedora, Baseball-Cap, respectively.
Assume that the chance of a card having each of these traits is given by
$p_{(3,1)} = 0.4, p_{(3,1)} = 0.3, p_{(3,3)} = 0.2, p_{(3,4)} = 0.1.$
This means that (for example) the probabilility of a card having No Hat is $0.4$, while the probability of a card having the Hat of Baseball-Cap is $0.1$.
Now, consider determining how rare a certain card is.
Suppose that the card has the traits of
Background = Red, $p_{(1,2)} = 0.3$.
Clothing = Shirt+Pants, $p_{(2,3)} = 0.4$.
Hat = No Hat, $p_{(3,1)} = 0.4$.
Then, the rarity of this particular card is
$$(0.3) \times (0.4) \times (0.4) = (0.048).$$
As a separate example, suppose that the card has the traits of
Background = No Background, $p_{(1,1)} = 0$.
Clothing = Shirt+Pants, $p_{(2,3)} = 0.4$.
Hat = No Hat, $p_{(3,1)} = 0.4$.
Then, the rarity of this particular card is
$$(0) \times (0.4) \times (0.4) = (0).$$
As a third example, suppose that the card has the traits of
Background = Blue, $p_{(1,3)} = 0.2$.
Clothing = Tuxedo, $p_{(2,2)} = 0.6$.
Hat = Fedora, $p_{(3,3)} = 0.2$.
Then, the rarity of this particular card is
$$(0.2) \times (0.6) \times (0.2) = (0.024).$$