Пример #1
0
8/28: plt.xlabel("$k$")
8/29: plt.title("Probability mass funciton of a Poisson random \$\lambda$ values")
8/30: plt.show()
 9/1: from pymc import DiscreteUniform, Exponential, deterministic, Poisson, Uniform
 9/2: import numpy as np
 9/3:
disasters_array =   \
     np.array([ 4, 5, 4, 0, 1, 4, 3, 4, 0, 6, 3, 3, 4, 0, 2, 6,
                   3, 3, 5, 4, 5, 3, 1, 4, 4, 1, 5, 5, 3, 4, 2, 5,
                   2, 2, 3, 4, 2, 1, 3, 2, 2, 1, 1, 1, 1, 3, 0, 0,
                   1, 0, 1, 1, 0, 0, 3, 1, 0, 3, 2, 2, 0, 1, 1, 1,
                   0, 1, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 1, 1, 0, 2,
                   3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 4, 2, 0, 0, 1, 4,
                   0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1])
 9/4: switchPoint = DiscreteUniform('switchpoint', lower=0, upper=110, doc='Switchpoint[year]')
 9/5: early_mean = Exponential('early_mean', beta=1.)
 9/6: late_mean = Exponential('late_mean', beta=1.)
 9/7:
@deterministic(plot=false)
def rate(s=switchPoint, e=early_mean, l=late_mean):
    ''' Concatyente Poisson means '''
    out = np.empty(len(disasters_array))
    out[:s] = e
    out[s:] = l
    return out
 9/8:
@deterministic(plot=False)
def rate(s=switchPoint, e=early_mean, l=late_mean):
    ''' Concatyente Poisson means '''
    out = np.empty(len(disasters_array))
    out[:s] = e
    # DISTRIBUCION EXPONENCIAL
    elif optionSelected == 3:

        os.system("cls")
        nombreDistribucion = "Distribución Exponencial"
        print("\t::", nombreDistribucion, "::")

        # Parametros necesarios para la generació1n
        media = float(input("->Ingrese la media :"))
        numeroDatos = int(input("->Ingrese el número de variables aleatorias a generar :"))
        #nivelDeSignificacia = float(input("->Ingrese el nivel de significancia para la prueba chi cuadrado :"))
        nivelDeSignificacia = 0.05

        tipoDistribucion = st.expon(1, media)

        objExpon = exponDistribution.Exponential(numeroDatos, tipoDistribucion, nivelDeSignificacia, nombreDistribucion,
                                                 media)

        legendHistogram =  r'$\mu$' + "="+ str("{0:.2f}".format(objExpon.meanGenerated))
        legendDensity = r'$\mu$' + "=" + str(objExpon.mean)

        axisX = np.linspace(1, objExpon.mean + 6 * objExpon.des, 100)

        objExpon.chiSquareTest()
        objExpon.graph(legendHistogram, legendDensity, axisX)


    # DISTRIBUCION ERLANG
    elif optionSelected == 4:
        os.system("cls")

        nombreDistribucion = "Distribución Erlang"