Talk:Functional coverage tree: Difference between revisions
Content added Content deleted
(→Data in a more functional form: Weighted sums.) |
|||
Line 45: | Line 45: | ||
I did not use the above, but thought I should generate it. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 20:02, 12 August 2015 (UTC) |
I did not use the above, but thought I should generate it. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 20:02, 12 August 2015 (UTC) |
||
===Weighted sums=== |
|||
The specified weights look like they are meant to be percentages (all=100), but the specification for missing weights seems to be fractional (all=1). I think that this deserves either a bit more explanation (as to why the use of "1" for default weight is correct) or correction. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 01:53, 13 August 2015 (UTC) |
|||
:Hi Rdm, Those weights are not percentages - They are "fractions of the sum of the weights" at that level. I was playing around with what weight to apply to house1 and house2 and rejected 1, 2 then eventually considered 2, 3 and realised that for those integers it would be the same as 5, 6 and 40, 60 - saw the total weight of being 100 and the |
|||
:# Ease of hand calculation. |
|||
:# Similarity to prcentages. |
|||
:And so went with that. Never thinking that it might confuse rather than help. |
|||
:Here are some doodles around the weighted average calculation: |
|||
:<lang python>>>> def wt_avg(wt, cov): |
|||
... wts = sum(wt) |
|||
... covs = sum(c * w for c, w in zip(cov, wt)) |
|||
... return covs / wts |
|||
... |
|||
>>> weights = [1, 1] |
|||
>>> child_cov = [0.5, 0.5] |
|||
>>> wt_avg(weights, child_cov) |
|||
0.5 |
|||
>>> weights = [2, 3] |
|||
>>> wt_avg(weights, child_cov) |
|||
0.5 |
|||
>>> weights = [1, 1] |
|||
>>> child_cov = [0.25, 0.75] |
|||
>>> wt_avg(weights, child_cov) |
|||
0.5 |
|||
>>> weights = [2, 3] |
|||
>>> wt_avg(weights, child_cov) |
|||
0.55 |
|||
>>> weights = [4, 6] |
|||
>>> wt_avg(weights, child_cov) |
|||
0.55 |
|||
>>> weights = [40, 60] |
|||
>>> wt_avg(weights, child_cov) |
|||
0.55 |
|||
>>> |
|||
>>> # From wikipedias basic example: |
|||
>>> weights = [20, 30] |
|||
>>> child_cov = [80, 90] |
|||
>>> wt_avg(weights, child_cov) |
|||
86.0 |
|||
>>> </lang> |