def init(inp): global d d = inp if 'jelleg' in d: d['hip'] = g.sigmahip(j=g.jellegT[d['jelleg']], sigma0=d['sigma0']) X = np.array(d['X']) n = d['n'] = len(X) df = n - 1 d['sumval'] = np.sum(X) d['sumjel'] = g.sumjel(X[0], X[n - 1]) d['meanval'] = d['mu'] d['meanjel'] = f2s(d['meanval']) #d['diffval']=d['meanval']-d['mu0'] #d['diffjel']=r'{mean}-{mu0}'.format(mean=f2s(d['meanval']), mu0=f2s(d['mu0'])) d['sum2jel'] = g.sum2jel(X[0], X[n - 1], d['meanval']) d['sum2val'] = np.sum((X - d['meanval'])**2) d['sjel'] = br(frac(d['sum2jel'], str(df))) + r'^\frac{1}{2}' d['sval'] = np.std(X, ddof=1) #d['errval']=d['sval']/np.sqrt(n) #d['errjel']=f2s(d['errval']) d['chi2val'] = df * (d['sval'] / d['sigma0'])**2 d['chi2jel'] = str(df) + br(frac(f2s(d['sval']), f2s(d['sigma0']))) + r'^2' alfa = d['alfa'] d['krit']=[chi2crit(1-alfa,df), chi2crit(1-0.5*alfa,df), \ chi2crit(alfa,df), chi2crit(0.5*alfa,df)]
def init(inp): global d d = inp if 'jelleg' in d: d['hip'] = g.muhip(j=g.jellegT[d['jelleg']], mu0=d['mu0']) X = np.array(d['X']) n = d['n'] = len(X) df = n - 1 d['sumval'] = np.sum(X) d['sumjel'] = g.sumjel(X[0], X[n - 1]) d['meanval'] = np.mean(X) d['meanjel'] = frac(d['sumjel'], str(n)) d['diffval'] = d['meanval'] - d['mu0'] d['diffjel'] = r'{mean}-{mu0}'.format(mean=f2s(d['meanval']), mu0=f2s(d['mu0'])) d['sum2jel'] = g.sum2jel(X[0], X[n - 1], d['meanval']) d['sum2val'] = np.sum((X - d['meanval'])**2) d['sjel'] = br(frac(d['sum2jel'], str(df))) + r'^\frac{1}{2}' d['sval'] = np.std(X, ddof=1) d['errval'] = d['sval'] / np.sqrt(n) d['errjel'] = f2s(d['errval']) d['tval'] = d['diffval'] / d['errval'] d['tjel']=frac(d['diffjel'], d['errjel'])+'='+\ frac(f2s(d['diffval']),d['errjel']) alfa = d['alfa'] d['krit'] = [tcrit(1 - alfa, df), tcrit(1 - 0.5 * alfa, df)]
def perform(): out = r'1-mintás $\chi^2$-próba\newline' + ujsor out += r'\Mat{' + ujsor n = d['n'] out += r'n={n}'.format(n=n) + mujsor out += r's = ' + d['sjel'] + ' = ' + mujsor out += r' = ' + br(frac(f2s(d['sum2val']), str(n - 1))) + r'^{\frac{1}{2}}' out += r' = {s}'.format(s=f2s(d['sval'])) + mujsor out += r'\chi^2 = ' + d['chi2jel'] + ' = ' + f2s(d['chi2val']) + mujsor out += d['krit'][0] + r'\hspace{1cm}' + d['krit'][1] + mujsor out += d['krit'][2] + r'\hspace{1cm}' + d['krit'][3] print(out + '\n' + r'}' + ujsor)
def perform(): out = r'1-mintás z-próba\newline' + ujsor out += r'\Mat{' + ujsor #out+=d['hip']+mujsor out += r'n={n}'.format(n=d['n']) + mujsor out += g.atlag(sumjel=d['sumjel'], sumval=f2s(d['sumval']), n=d['n'], res=f2s(d['meanval'])) + mujsor out += r'z = ' + d['zjel'] + ' = ' + f2s(d['zval']) + mujsor out += d['krit'][0] + r'\hspace{1cm}' + d['krit'][1] print(out + '\n' + r'}' + ujsor)
def init(inp): global d d = inp if 'jelleg' in d: d['hip'] = g.muhip(j=g.jellegT[d['jelleg']], mu0=d['mu0']) X = d['X'] n = d['n'] = len(X) d['sumval'] = np.sum(X) d['sumjel'] = g.sumjel(X[0], X[n - 1]) d['meanval'] = np.mean(X) d['meanjel'] = r'\frac{{{sumjel}}}{{{n}}}'.format(sumjel=d['sumjel'], n=n) d['diffval'] = d['meanval'] - d['mu0'] d['diffjel'] = r'{mean}-{mu0}'.format(mean=f2s(d['meanval']), mu0=f2s(d['mu0'])) d['errval'] = d['sigma'] / np.sqrt(n) d['errjel'] = f2s(d['errval']) d['zval'] = d['diffval'] / d['errval'] d['zjel']=r'\frac{{{diffjel}}}{{{errjel}}}'.format(diffjel=d['diffjel'],errjel=d['errjel'])+'='+\ r'\frac{{{diffval}}}{{{errjel}}}'.format(diffval=f2s(d['diffval']),errjel=d['errjel']) alfa = d['alfa'] d['krit'] = [zcrit(1 - alfa), zcrit(1 - 0.5 * alfa)]
def perform(): out = r'1-mintás t-próba\newline' + ujsor out += r'\Mat{' + ujsor n = d['n'] out += r'n={n}'.format(n=n) + mujsor out += g.atlag(sumjel=d['sumjel'], sumval=f2s(d['sumval']), n=n, res=f2s(d['meanval'])) + mujsor out += r's = ' + d['sjel'] + ' = ' + mujsor out += r' = ' + br(frac(f2s(d['sum2val']), str(n - 1))) + r'^{\frac{1}{2}}' out += r' = {s}'.format(s=f2s(d['sval'])) + mujsor out += r'\frac{{s}}{{\sqrt{n}}}' + ' = ' + frac(f2s( d['sval']), f2s(np.sqrt(n))) + ' = ' + f2s(d['errval']) + mujsor out += r't = ' + d['tjel'] + ' = ' + f2s(d['tval']) + mujsor out += d['krit'][0] + r'\hspace{1cm}' + d['krit'][1] print(out + '\n' + r'}' + ujsor)
def perform(): out = r'1-mintás arány-próba\newline' + ujsor out += r'\Mat{' + ujsor n = d['n'] out += d['errjel1'] + ' = ' + d['errjel2'] + ' = ' + f2s( d['errval']) + mujsor out+=r'z='+frac(d['diffjel'],f2s(d['errval']))+'='\ +frac(f2s(d['diffval']), f2s(d['errval']))+' = '+f2s(d['zval'],4)+mujsor out += r'\text{küszöb}=' + d['thrjel'] + ' = ' + f2s(d['thrval']) + mujsor out += d['krit'][0] + r'\hspace{1cm}' + d['krit'][1] + mujsor out += d['krit'][2] + r'\hspace{1cm}' + d['krit'][3] print(out + '\n' + r'}' + ujsor)
def init(inp): global d d = inp n = d['n'] k = d['k'] p0 = d['p0'] phat = k / n alfa = d['alfa'] d['diffval'] = phat - p0 d['diffjel'] = f2s(phat) + '-' + f2s(p0) d['errval'] = np.sqrt(p0 * (1 - p0) / n) s = f2s(p0) + br('1-' + f2s(p0)) sval = p0 * (1 - p0) d['errjel1'] = br(frac(s, str(n))) + r'^\frac{1}{2}' d['errjel2'] = br(frac(f2s(sval), str(n))) + r'^\frac{1}{2}' d['zval'] = d['diffval'] / d['errval'] d['zjel'] = frac(d['diffjel'], f2s(d['errval'])) d['thrval'] = n * min(p0, 1 - p0) d['thrjel'] = str(n) + r'\min(' + f2s(p0) + ',' + f2s(1 - p0) + r')' d['krit']=[zcrit(1-alfa), zcrit(1-0.5*alfa), \ zcrit(alfa), zcrit(0.5*alfa)]
def zcrit(p): return (r'z_{{{a}}}={{{za}}}'.format(a=f2s(p, 3), za=f2s(norm.ppf(p), 3)))
def chi2crit(p, df): return (r'\chi^2_' + cbr(f2s(p, 3) + r',\ df=' + str(df)) + '=' + f2s(chi2.ppf(p, df), 3))
def tcrit(p, df): return (r't^{{({df})}}_{{{a}}}={ta}'.format(df=df, a=f2s(p, 3), ta=f2s(t.ppf(p, df), 3)))