## Recommended Posts

Just trying to wrap my head around some (very) basic math here by converting it into AU3 syntax, on this page (http://www.paulgraham.com/naivebayes.html) there is a good example of how to add two, or more, probabilities together. Here's the short version:

If a and b are the probabilities associated with two independent pieces of evidence [that someone is a basketball player], then combined they indicate a probability of:

ab
-------------------
ab + ( 1 - a )( 1 - b )

So in this case our answer is:

(.60)(.72)
-------------------------------
(.60)(.72) + (1 - .60)(1 - .72)

which is .794. There is a 79.4% chance that the person is a basketball player.

Now, any takes on how I would implement that simple math in autoit code? For now I've got:

```\$prbs = 0.60 + 0.72
\$dividers = ((0.60+0.72))+((1-0.60)+(1-0.72))
\$result = \$prbs / \$dividers
ConsoleWrite('\$result: ' & \$result & @CRLF)```

And the output is "0.66" which certainly isn't right so I'm doing something wrong, any takers/helpers on this problem?

Edited by Sunaj

##### Share on other sites

ab = a * b, not a + b.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

ab = a * b, not a + b.

Ah so simple, thank you. After writing code to accumulate/calculate conditional probabilities (in PHP) I was stuck on how to combine them, this solves it nicely (and makes a good case for learning a bit of basic math notation), here's the fixed code in case someone should stumble on this subject down the road:

```\$prbs = 0.60 * 0.72
\$dividers = ((0.60*0.72))+((1-0.60)*(1-0.72))
\$result = \$prbs / \$dividers
ConsoleWrite('\$result: ' & \$result & @CRLF)```

##### Share on other sites

It's been a LOOONNNGGG time since I've sat in a math class, good to know I haven't forgotten everything yet.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

## Create an account

Register a new account

• ### Similar Content

• By MrCheese
hi all,
Dumb question, but say I have a loop:
dim \$i Do     sleep(1000)          if \$i = ; how do i do a function that enters this IF statement every 10 loops?         ; do stuff every 10     EndIf      Until \$i = 100
- what commands in the if statement do I need to use to make it pass, and on every 10th loop, it enters the if statement. ?

Thanks
• By jrsofsd
RunningStats calculates running (moving) statistics: Standard Deviation, Variance, and Mean . The single function _RunningStats(), queries, clears, restores, or adds to the running statistics.
Example.au3 adds 7 samples of data to running statistics and displays the results using _ArrayDisplay().
Example-Persistent-Storage.au3 adds the first 6 samples to the running statistics and stores the results in an INI file. The data is read from the INI file and restored to the running statistics. The 7th sample is added and the results displayed, matching the results from Example.au3.
Credits: John D. Cook for his article "Accurately computing running variance" at http://www.johndcook.com/blog/standard_deviation/
RunningStats.zip

• I started writing this UDF a while ago, so I decided to share it here.
This is an UDF full of advanced mathematical functions. It allows to work with primes, create number sequences, interpolate, calculate values of functions like Riemann zeta.
Full list of functions:

Changelog:

• Hey there
I'm thinking about making a program that will calculate with huge numbers. Well above 1*10^18 probably. Can autoit deal with that? If not, how can I make it work?
Thanks!
• By rm4453
I keep getting error : Statement cannot be just an expression.
Here are the 3 error variations it gives:
Global \$ImageCount += 1
~~~~~~~~~~~~~~~~~~~~~^
Global \$ImageCount += 1
~~~~~~~~~~~~~~~~~~~~^
Global \$ImageCount +=
~~~~~~~~~~~~~~~~~~~^
Here is the code:
Case \$Image1 ;GUICtrlSetState(\$Image1, 4+128) GUICtrlSetState(\$Image2, 64) \$Image1_done = 1 OpenImages() Global \$Image1_added = \$imagePath ;MsgBox("Info", "Image 1 Path", \$Image1_added) OpenEditBox() Global \$Image1_Description = \$editBox_save If \$im1 = 0 Then Global \$ImageCount += 1 \$im1 = 1 EndIf Case \$Image2 If \$Image1_done = 1 Then ;GUICtrlSetState(\$Image2, 4+128) GUICtrlSetState(\$Image3, 64) OpenImages() Global \$Image2_added = \$imagePath ;MsgBox("Info", "Image 2 Path", \$Image2_added) OpenEditBox() Global \$Image2_Description = \$editBox_save \$Image2_done = 1 If \$im2 = 0 Then Global \$ImageCount += 1 \$im2 = 1 EndIf Else EndIf Case \$Image3 If \$Image2_done = 1 Then ;GUICtrlSetState(\$Image3, 4+128) GUICtrlSetState(\$Image4, 64) OpenImages() Global \$Image3_added = \$imagePath ;MsgBox("Info", "Image 3 Path", \$Image3_added) OpenEditBox() Global \$Image3_Description = \$editBox_save \$Image3_done = 1 If \$im3 = 0 Then Global \$ImageCount += 1 \$im3 = 1 EndIf Else EndIf Case \$Image4 If \$Image3_done = 1 Then ;GUICtrlSetState(\$Image4, 4+128) GUICtrlSetState(\$Image5, 64) OpenImages() Global \$Image4_added = \$imagePath ;MsgBox("Info", "Image 4 Path", \$Image4_added) OpenEditBox() Global \$Image4_Description = \$editBox_save \$Image4_done = 1 If \$im4 = 0 Then Global \$ImageCount += 1 \$im4 = 1 EndIf Else EndIf Case \$Image5 If \$Image4_done = 1 Then ;GUICtrlSetState(\$Image5, 4+128) GUICtrlSetState(\$Image6, 64) OpenImages() Global \$Image5_added = \$imagePath ;MsgBox("Info", "Image 5 Path", \$Image5_added) OpenEditBox() Global \$Image5_Description = \$editBox_save \$Image5_done = 1 If \$im5 = 0 Then Global \$ImageCount += 1 \$im5 = 1 EndIf Else EndIf Case \$Image6 If \$Image1_done = 1 Then ;GUICtrlSetState(\$Image6, 4+128) OpenImages() Global \$Image6_added = \$imagePath ;MsgBox("Info", "Image 6 Path", \$Image6_added) OpenEditBox() Global \$Image6_Description = \$editBox_save If \$im6 = 0 Then Global \$ImageCount += 1 \$im6 = 1 EndIf Else EndIf
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...