Hallo,
ich wollte mal wieder etwas programmieren und da ich in Mathe zurzeit Statistik habe, habe ich angefangen einen Statistik Rechner zu programmieren.
Bisher kann man die Varianz und die Standardabweichung ausrechnen.
Skript
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $ges = 0, $var = 0, $nach = 2, $trenn = ";", $liste = "", $label1, $edit_liste, $label2, $input_trenn, $label3, $input_nach, $label4, $input_vari, $Label5, $input_abwei, $button_rechnen
[/autoit] [autoit][/autoit] [autoit]$gui = GUICreate("Varianz Rechner", 361, 311)
_Create()
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $button_rechnen
$str = StringSplit(GUICtrlRead($edit_liste), GUICtrlRead($input_trenn))
For $i = 1 To $str[0]
$ges += $str[$i]
Next
$mittel = $ges / $str[0]
For $i = 1 To $str[0]
$var += ($str[$i] - $mittel) ^ 2
Next
$varianz = (1 / ($str[0] - 1)) * $var
$standard = $varianz ^ 0.5
$pos = WinGetPos($gui)
If $pos[3] = 425 Then
_Set()
Else
WinMove($gui, "", $pos[0], $pos[1], $pos[2], 425)
$nach = GUICtrlRead($input_nach)
$trenn = GUICtrlRead($input_trenn)
$liste = GUICtrlRead($edit_liste)
_Del()
_Create()
_Set()
EndIf
EndSwitch
WEnd
Func _Runden($z)
$z_s = StringSplit($z, ".")
If @error Then Return ($z)
$tre = GUICtrlRead($input_nach)
$1 = StringLeft($z_s[2], $tre - 1)
$z_s[2] = StringTrimLeft($z_s[2], $tre - 1)
$2_u = StringLeft($z_s[2], 1)
$z_s[2] = StringTrimLeft($z_s[2], 1)
If StringLeft($z_s[2], 1) > 4 Then
$2 = $2_u + 1
Else
$2 = $2_u
EndIf
$zahl = $z_s[1] & "." & $1 & $2
Return ($zahl)
EndFunc ;==>_Runden
Func _Set()
GUICtrlSetData($input_vari, _Runden($varianz))
GUICtrlSetData($input_abwei, _Runden($standard))
$var = 0
$ges = 0
EndFunc ;==>_Set
Func _Create()
$label1 = GUICtrlCreateLabel("Datensatz (nur Zahlen und Trennzeichen):", 8, 8, 288, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$edit_liste = GUICtrlCreateEdit($liste, 8, 32, 350, 200, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL))
GUICtrlSetData(-1, "")
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$label2 = GUICtrlCreateLabel("Trennzeichen:", 8, 240, 100, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$input_trenn = GUICtrlCreateInput($trenn, 112, 240, 41, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$label3 = GUICtrlCreateLabel("Nachkommastellen:", 160, 240, 140, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$input_nach = GUICtrlCreateInput($nach, 304, 240, 41, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$label4 = GUICtrlCreateLabel("Varianz:", 8, 320, 61, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$input_vari = GUICtrlCreateInput("", 72, 320, 150, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label5 = GUICtrlCreateLabel("Standardabweichung:", 8, 368, 155, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$input_abwei = GUICtrlCreateInput("", 168, 368, 150, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$button_rechnen = GUICtrlCreateButton("Ausrechnen", 136, 272, 83, 33, $WS_GROUP)
EndFunc ;==>_Create
Func _Del()
GUICtrlDelete($label1)
GUICtrlDelete($edit_liste)
GUICtrlDelete($label2)
GUICtrlDelete($input_trenn)
GUICtrlDelete($label3)
GUICtrlDelete($input_nach)
GUICtrlDelete($label4)
GUICtrlDelete($input_vari)
GUICtrlDelete($Label5)
GUICtrlDelete($input_abwei)
GUICtrlDelete($button_rechnen)
EndFunc ;==>_Del
MfG Tobi