"""候補9: 画像ごとの模型の山の平均と、平均の寸法から組んだ模型の山の差。
表2の平均のまわりに、各寸法を独立に変動係数 cv の正規分布で揺らし（層数は ±1 の一様）、40 枚ぶんの重心の平均を取る。"""
import numpy as np, table2_model as m
from centroid_peak import both
rng = np.random.default_rng(1)
for cv in (0.1, 0.2):
    for patch in ('gorget', 'crown'):
        for sp in ('branickii', 'hybrid', 'gularis'):
            v = m.T2[(sp, patch)]; base = both(m.stack(*v))[1]
            cs = []
            for _ in range(40):
                air, cor, ker, lay, mel, ptt = [x*max(0.3, rng.normal(1, cv)) for x in v[:3]] + [max(2, v[3] + rng.integers(-1, 2))] + [x*max(0.3, rng.normal(1, cv)) for x in v[4:]]
                cs.append(both(m.stack(air, cor, ker, int(lay), mel, ptt))[1])
            print(f'cv{cv} {sp:9s} {patch:6s} 平均形態 {base:.0f}  画像ごとの平均 {np.mean(cs):.0f}  差 {np.mean(cs)-base:+.0f}', flush=True)
