o
    ?Íjg  ã                   @   sô   d Z ddlZddlmZmZ d dd„Zdd	„ Zd!dd„Zedkrxg d¢Z	dZ
ede› d�ƒ ee	ƒD ];\Z\ZZZZeeeeed�ƒ\ZZZe e¡Ze
eM Z
ederUdnd› ded›ded›ded›de› de› d�ƒ q2ee
rsdndƒ dS dS )"u  ðŸšªâž¡ï¸� The bootstrap â†’ door step for P2, IMPORTING doors.py (never re-typing the rules).

Takes per-trial contrast values (e.g. warned LSâˆ’LU for one model, one value per trial),
bootstraps a 95% interval over trials, and hands [L, U] to doors.door(). That's the whole job.

â›” This file reads NO warned data. The draft isn't sealed yet; the only thing run here is the
   self-test below, on SYNTHETIC trials with effects I planted, so we know the pipe can tell a
   persisting effect from a collapsed one from a reversed one BEFORE anything real goes through it.
   (Per-trial rate extraction from the run jsonl is a separate step and reuses the one parser,
   sha e3823fdc, from drm_armB_fences.py â€” one parser, not two.)

Heartbeat arm, 2026-10-12 morning.
é    N)ÚdoorÚDELTAé'  é”(5c                    sP   t  |¡‰tˆƒ‰ t‡ ‡‡fdd„t|ƒD ƒƒ}|td| ƒ |td| ƒ fS )z]95% percentile bootstrap of the MEAN over trials. Seeded so a rerun prints the same interval.c                 3   s0   � | ]}t ‡‡fd d„tˆ ƒD ƒƒˆ  V  qdS )c                 3   s   � | ]}ˆ   ˆ¡V  qd S ©N)Úchoice©Ú.0Ú_)ÚrngÚvalues© úC/home/Ace/liberation/same-standard/drm/sealed/drm_forewarn_doors.pyÚ	<genexpr>   s   € z$boot_ci.<locals>.<genexpr>.<genexpr>N)ÚsumÚranger   ©Únr   r   r   r   r      s   €. zboot_ci.<locals>.<genexpr>gš™™™™™™?g333333ï?)ÚrandomÚRandomÚlenÚsortedr   Úint)r   ÚBÚseedÚmeansr   r   r   Úboot_ci   s   
 r   c                 C   s   t | ƒ\}}||t||ƒfS r   )r   r   )Úper_trial_contrastÚLÚUr   r   r   Úp2_door   s   r    é   c                    s$   t  |¡‰‡ ‡‡fdd„t|ƒD ƒS )Nc                    s   g | ]}ˆ  ˆ ˆ¡‘qS r   )Úgaussr   ©Úmeanr   Úsdr   r   Ú
<listcomp>    s    z_synthetic.<locals>.<listcomp>)r   r   r   )r$   r%   r   r   r   r#   r   Ú
_synthetic   s   
r'   Ú__main__))zpersists, big effectçš™™™™™Ù?çš™™™™™¹?Ú1)zcollapsed, true zero, tightg        g¸…ëQ¸ž?z2 collapsed (spans 0))zcollapsed, small + residualçš™™™™™©?g{®Gáz„?z2 collapsed (+)Úreversedgš™™™™™Ù¿r*   ÚR)zboundary: wide, L just above 0r*   g333333Ó?r+   )zinconclusive, crosses 0 wider,   r)   Ú3Tu   Î´ = z0; 12 synthetic trials per case; 10,000 resamples)r   z  u   âœ…u   â�Œú Ú30sz [z+.3fz, z] -> z   (must be u   â€¦)u)   âœ… the pipe separates every planted caseuQ   â�Œ A PLANTED CASE LANDED IN THE WRONG DOOR â€” do not run real data through this)r   r   )r!   r   )Ú__doc__r   Údoorsr   r   r   r    r'   Ú__name__ÚcasesÚok_allÚprintÚ	enumerateÚiÚnameÚmur%   Úwantr   r   ÚdÚ
startswithÚokr   r   r   r   Ú<module>   s$    

>
ÿë