из __future__ импортировать подразделение импортировать numpy как np из scipy.special импортировать gammaincc импортировать matplotlib.pyplot как pltplt.style.use ( u " сиборн - белый " )def chifunc ( x , n ): return gammaincc ( n / 2 , x * n / 2 )красный = "#e41a1c" синий = "#377eb8" зеленый = "#4daf4a"M = 10 z = np.linspace ( 0.01 , 10 , 1000 ) a = ( 1-2 / ( 9 * M ) ) ** 3 nx = z < = a nx2 = z > = a чернов = ( z * np.exp ( 1 - z ) ) ** ( M / 2 ) plt.figure ( figsize = ( 5,3 ) ) plt.loglog ( z [ nx ] , 1 - chifunc ( z [ nx ] , M ) , цвет = красный ) plt.loglog ( z [ nx2 ] , chifunc ( z [ nx2 ] , M ) , цвет = синий , стильлинии = " пунктирная " ) plt.loglog ( z , chernoff , цвет = зеленый , стильлинии = " пунктирная " ) plt.xlim ( 0.01,10 ) plt.ylim ( 1e - 15,10 ) plt.yticks ( np.logspace ( -15,0,4 ) ) plt.legend ( [ " CDF " , " 1 - CDF " , " граница Чернова " ] , loc = " лучшая " ) plt . xlabel ( r "$z$" , fontsize = 15 ) plt . savefig ( "Chernoff-bound.svg" , bbox_inches = "tight" )