Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Proporcion.py #5

Merged
merged 5 commits into from
Nov 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 73 additions & 1 deletion Proporcion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,78 @@
"""
<summary>
Funcion menu que realiza la prueba de hipotesis de una proporcion.
</summary>
<param name="x">Numero de exitos en la muestra.</param>
<param name="n">Numero de ensayos en la muestra.</param>
<param name="alpha">Nivel de significancia.</param>
<param name="Z">Valor del estadistico de prueba.</param>
"""
def menu_proporcion():
return
print("Elige la prueba de hipotesis a utilizar:")
print("1.")
print("H0. " + Stheta + " = " + Stheta + "0")
print("H1. " + Stheta + " > " + Stheta + "0")
print("2.")
print("H0. " + Stheta + " = " + Stheta + "0")
print("H1. " + Stheta + " < " + Stheta + "0")
print("3.")
print("H0. " + Stheta + " = " + Stheta + "0")
print("H1. " + Stheta + " != " + Stheta + "0")
opcion = input("Opcion: ")
os.system("cls")

if opcion not in ["1", "2", "3"]:
print("Opcion incorrecta, vuelve a intentarlo.")
print("Presiona una tecla para continuar...")
os.system("pause")
os.system("cls")
menu_proporcion()
return

print("Prueba de hipotesis de proporciones")
print("H0. " + Stheta + " = " + Stheta + "0")
print("H1. " + Stheta + [">", "<", "!="][int(opcion) - 1] + Stheta + "0")
print("")
print("Introduce los datos:")
theta = float(input(Stheta+"0: "))
x = float(input("x: "))
n = int(input("n: "))
alpha = float(input(Salpha + ": "))
if opcion=="3":
alpha = 0.5 - alpha/2
else:
alpha = 0.5 - alpha
Z = (x - n*theta) / math.sqrt(n*theta*(1-theta))
prueba(Z, alpha, opcion)
os.system("cls")

"""
<summary>
Funcion que rechaza o no rechaza H0.
</summary>
<param name="Z">Valor de la prueba.</param>
<param name="alpha">Valor de alpha.</param>
<param name="opcion">Opcion de la prueba.</param>
"""
def prueba(Z, alpha, opcion):
if opcion == "1":
if Z > buscarZ(alpha):
print("Se rechaza H0.")
else:
print("No se rechaza H0.")
elif opcion == "2":
if Z < -buscarZ(alpha):
print("Se rechaza H0.")
else:
print("No se rechaza H0.")
elif opcion == "3":
if Z < -buscarZ(alpha) or Z > buscarZ(alpha):
print("Se rechaza H0.")
else:
print("No se rechaza H0.")
print("Presiona una tecla para continuar...")
os.system("pause")
os.system("cls")
return

menu_proporcion()