Okay, so first, for each vehicle type, compute the inverse weight as 1 / points. Normalize these weights to convert them into probabilities summing to 100%. This is done by dividing each weight by the total sum of all weights. Ensure the probabilities sum exactly to 100% by adjusting the last probability. For each vehicle type, compute the absolute difference between John's probability and the city's frequency and then sum all these differences. Subtract the total difference from 100% to calculate the match percentage: Match Percentage = 100 - Σ|P(Jhon) - P(City)|. If the match percentage is negative, set it to 0.
Here is an example: Points: [1, 3, 5, 6] City Frequencies: [58.82%, 19.61%, 11.76%, 9.81%] | Weight=[1, 1/3 ,1/5 ,1/6] | Sum of weights = 1.7 | Probabilities= [1/1.7, 0.33/1.7, 0.2/1.7, (1/6)/1.7]*100= | Probabilities = [58.82, 19.61, 11.76, 9.81] | In this case the sum is already 100%, so no adjustment is needed. | Differences= |58.82 - 58.82| + |19.61 - 19.61| + |11.76 - 11.76| + |9.81 - 9.81| = 0 | Match Percentage = 100 - 0 = 100.00%
The "match percentage" in this context measures how closely John’s point-based probability distribution aligns with the actual frequency distribution of vehicle types in the city. The purpose is to assess how well John's point system predicts the city's actual vehicle distribution. A high match percentage means the point system effectively captures real-world probabilities, while a low percentage suggests it deviates significantly, potentially making the game less representative of actual trends.
Okay, thanks so much!
Okay, so first, for each vehicle type, compute the inverse weight as 1 / points. Normalize these weights to convert them into probabilities summing to 100%. This is done by dividing each weight by the total sum of all weights. Ensure the probabilities sum exactly to 100% by adjusting the last probability. For each vehicle type, compute the absolute difference between John's probability and the city's frequency and then sum all these differences. Subtract the total difference from 100% to calculate the match percentage: Match Percentage = 100 - Σ|P(Jhon) - P(City)|. If the match percentage is negative, set it to 0.
Here is an example: Points: [1, 3, 5, 6] City Frequencies: [58.82%, 19.61%, 11.76%, 9.81%] | Weight=[1, 1/3 ,1/5 ,1/6] | Sum of weights = 1.7 | Probabilities= [1/1.7, 0.33/1.7, 0.2/1.7, (1/6)/1.7]*100= | Probabilities = [58.82, 19.61, 11.76, 9.81] | In this case the sum is already 100%, so no adjustment is needed. | Differences= |58.82 - 58.82| + |19.61 - 19.61| + |11.76 - 11.76| + |9.81 - 9.81| = 0 | Match Percentage = 100 - 0 = 100.00%
Fixed
Random tests are vulnerable to input modification
Can I have some worked examples of the match percentage calculation? What formula do you use to derive the percentage?
The description is fine but the specifics are a mystery to me.
The "match percentage" in this context measures how closely John’s point-based probability distribution aligns with the actual frequency distribution of vehicle types in the city. The purpose is to assess how well John's point system predicts the city's actual vehicle distribution. A high match percentage means the point system effectively captures real-world probabilities, while a low percentage suggests it deviates significantly, potentially making the game less representative of actual trends.
How is a "match percentage" defined?
What does it mean to "calculate the alignment"?
You can republish the kata when you think it's ok.
I think i fixed it
Thank you! I think I solved the problem.
Asking to round floats and render these in strings is asking for issues. Instead, ask for floating point and use approximate equality.
Random tests are not random.