"""Own cosine samples expose ambiguity; not an ADC or a resampling filter."""
import math,json
def sample(f,rate,n,phase=0):return [math.cos(2*math.pi*f*i/rate+phase) for i in range(n)]
def demo():
    a=sample(1000,8000,16);b=sample(7000,8000,16);high_a=sample(1000,16000,32);high_b=sample(7000,16000,32)
    same=max(abs(x-y) for x,y in zip(a,b));different=max(abs(x-y) for x,y in zip(high_a,high_b))
    assert same<1e-12 and different>1
    skipped=high_b[::2];assert max(abs(x-y) for x,y in zip(skipped,b))<1e-12
    nyquist_zero=[math.sin(2*math.pi*4000*i/8000) for i in range(16)]
    assert max(map(abs,nyquist_zero))<1e-12
    return {'cosines_hz':[1000,7000],'low_rate_hz':8000,'low_samples_each':16,'low_sample_vectors':[a,b],'max_abs_low_difference':same,'high_rate_hz':16000,'high_samples_each':32,'max_abs_high_difference':different,'decimate_by_two_without_filter_matches_ambiguous_8000_samples':True,'sine_at_exact_half_rate_phase_zero_max_abs':max(map(abs,nyquist_zero)),'any_filter_or_resample_poly_executed':False,'continuous_original_identified_from_low_samples':False,'speech_quality_or_ASR_accuracy_measured':False}
if __name__=='__main__':print(json.dumps(demo(),ensure_ascii=False,indent=2))
