Four Fortran 95 programmes.

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

User avatar
Ajedrecista
Posts: 2114
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Four Fortran 95 programmes.

Post by Ajedrecista »

Hello to everybody:

First of all, these are not chess programmes: these are three 'statistical' programmes, as explained here:

Three Fortran Programs
Steve R. wrote:Statistical programs for interpreting test results by Jesús Muñoz
http://www14.zippyshare.com/v/95422764/file.html


1- LOS and Elo uncertainties calculator
Programme for calculate uncertainties (± Elo) in a match between two engines, and likelihood of superiority (LOS).


2- Minimum number of games
Programme for calculate the minimum number of needed games to ensure an Elo gain with a given LOS value.


3- Minimum score for no regression
Programme for calculate the minimum score required for avoiding regression with a given LOS value.
The link died on October, 27th IIRC. The reason for open this topic is that someone (user Richard_1977 of Chess2U Forum) has requested the package; these programmes were optimized after I uploaded them but I did not release these updates... until now!

Four_Fortran_95_programmes.rar (0.63 MB)

The title of this topic says four programmes: I also include a Round Robin pairings generator up to 64 players, that I uploaded and the file also expired; this generator was also optimized and was unreleased until now, again.

All the source codes are included. I have been obtaining very similar results for months when comparing with other people, so I think that they are trustable... and faster now!

Regards from Spain.

Ajedrecista.
Carlos777
Posts: 1933
Joined: Sun Dec 13, 2009 6:09 pm

Re: Four Fortran 95 programmes.

Post by Carlos777 »

Very useful programs Jesús.

Gracias,
Carlos
User avatar
Ajedrecista
Posts: 2114
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Six Fortran 95 tools.

Post by Ajedrecista »

Hello!

I have been working a little on two new programmes and I changed a few things in my other four programmes, including minor cosmetic changes. Here are the main changes that I remember:

LOS_and_Elo_uncertainties_calculator:

Now I use sample standard deviations (divide by (n - 1) instead of n). The rest remains unchanged.

Minimum_number_of_games:

Now I use sample standard deviations (divide by (n - 1) instead of n). The rest remains unchanged.

Minimum_score_for_no_regression:

Now I use sample standard deviations (divide by (n - 1) instead of n). The rest remains unchanged. I include an expansion of Ciarrochi's table (the original one can be visited here).

Probabilities_in_a_trinomial_distribution:

A new programme. It calculates probabilities without using an approach of mean and sample standard deviation of a normal distribution. It is valid for matches between two engines but it can be also used with the average of ratings of a pool of several players/engines as a rough approximation. The only similar thing I know is this Tournament Performance Luck Calculator, but Probabilities_in_a_trinomial_distribution has more freedom because you can choose the draw ratio.

It has a drawback: the intensive use of RAM. When I open Task Manager, Probabilities_in_a_trinomial_distribution and salflibc.dll use almost 800 MB of RAM: it is due to huge size of arrays and most of the elements of arrays are never used. Well, I am not a programmer... I tried allocatable but things were incredibly slow so I discarded this method (by the way I do not know how exactly works and I surely used it in a wrong way). Anyway, the longest calculations should take a few seconds at maximum.

Rating_performances_for_Round_Robin_tournaments:

Other new programme: a very simple rating programme (without covariance, draw model, prior and other things) that is useful only for Round Robin tournaments, but it does not need PGN files and it gives very similar results when compared to EloSTAT. It supports up to 64 engines/players but this number can be increased easily in the source code. Here is an example:

Re: War Engines

Code: Select all

    Program                          Elo    +   -   Games   Score   Av.Op.  Draws  
 1 Houdini 3 Pro x64              : 3332   17  17   1000    69.8 %   3187   39.4 %  
 2 Critter 1.6a 64-bit            : 3247   14  14   1000    57.4 %   3195   55.2 %  
 3 Strelka 5.5 x64                : 3244   15  15   1000    56.9 %   3196   49.0 %  
 4 Komodo 5 64-bit                : 3226   16  16   1000    54.1 %   3198   45.0 %  
 5 Bouquet _1.6 x64               : 3196   15  15   1000    49.4 %   3201   53.8 %  
 6 RobboLito 0.21Q x64            : 3195   15  15   1000    49.2 %   3201   51.7 %  
 7 IvanHoe 9.46h x64              : 3185   14  14   1000    47.5 %   3202   56.5 %  
 8 Deep Rybka 4.1 x64             : 3180   16  16   1000    46.8 %   3202   45.1 %  
 9 Stockfish 2.3.1 JA 64bit       : 3171   16  16   1000    45.4 %   3203   44.7 % 
10 DeepSaros 3.3 x64              : 3168   14  14   1000    44.9 %   3203   54.8 % 
11 Chiron 1.5 64bit               : 3056   18  18   1000    28.6 %   3215   36.8 %

ELOstat > Start Elo = 3200
Here is what must be written in a Notepad at the same path that Rating_performances_for_Round_Robin_tournaments:

Code: Select all

698
574
569
541
494
492.5
475.5
467.5
453.5
449
286
And here is the input data on the programme once it is opened (double click on the executable):

Code: Select all

Rating_performances_for_Round_Robin_tournaments, ® 2012-2013.

Write down the full name of the Notepad (including .txt), up to 64 characters:

War_engines.txt

Write down the number of engines of the Round Robin tournament (up to 64):

11

Write down your desired mean of ratings between -5000 and 5000:

3200

Write down the clock rate of the CPU (in GHz), only for timing the elapsed time of the calculations:

3

Rating performances have been saved into List_of_rating_performances.txt file.

Approximated elapsed time:   26 ms.

Thanks for using Rating_performances_for_Round_Robin_tournaments. Press Enter to exit.

Code: Select all

Round Robin with 11 engines and   1000 games per engine.
Total number of games:      5500 games.
 
 Engines:     Performance:     Score:
 
Engine 01:      3331.13       69.80 %
Engine 02:      3246.77       57.40 %
Engine 03:      3243.57       56.90 %
Engine 04:      3225.84       54.10 %
Engine 05:      3196.39       49.40 %
Engine 06:      3195.46       49.25 %
Engine 07:      3184.81       47.55 %
Engine 08:      3179.79       46.75 %
Engine 09:      3170.98       45.35 %
Engine 10:      3168.14       44.90 %
Engine 11:      3057.11       28.60 %
 
Mean of ratings:  3200.00 Elo.
Rating(Houdini 3) - rating(Chiron 1.5) = 3332 - 3056 = 276 using EloSTAT; the same difference with my programme is 3331.13 - 3057.11 = 274.02 (less than 1% of difference between EloSTAT and Rating_performances_for_Round_Robin_tournaments). All the cases I have tried ended with a difference of less than 1%.

Round_Robin_pairings_generator:

The maximum number of players/engines supported is now 80 instead of 64.

------------------------

I have uploaded my tools (including source codes) in Dropbox this time, with the aim of get a permanent link:

Six_Fortran_95_tools.rar (681.58 KB)

Please remember that these executables should only work in Windows. These programmes are far to be perfect... I do not expect bugs but probably they exist in very extreme cases. Any insights are welcome. Enjoy!

Regards from Spain.

Ajedrecista.
Adam Hair
Posts: 3226
Joined: Wed May 06, 2009 10:31 pm
Location: Fuquay-Varina, North Carolina

Re: Six Fortran 95 tools.

Post by Adam Hair »

Thanks, Jesús!
User avatar
Ajedrecista
Posts: 2114
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: Six Fortran 95 tools.

Post by Ajedrecista »

Hi again:

I forgot to write an important thing in the Readme file of Rating_performances_for_Round_Robin_tournaments and also on my previous post: this programme does not accept engines/players with scores of 0% and/or 100%. If you try this cases you will only get a message and nothing more:
Rating_performances_for_Round_Robin_tournaments does not support scores of neither 0% nor 100%.

Please close and try again. Press Enter to exit.
It is due to the model I use:

Code: Select all

delta(i) = 4d2*log10(points(i)/(games_per_engine - points(i)))  ! By definition.
Since I use logarithms, then the extreme cases of score = 0% or score = 100% imply that a zero will appear in the numerator or in the denominator and it will bring problems. This is the reason why I check scores before doing calculations.

Code: Select all

  if ((points(i) == 0d0) .or. (points(i) == games_per_engine)) then
    write(*,'(A)') 'Rating_performances_for_Round_Robin_tournaments does not support scores of neither 0% nor 100%.'
    write(*,*)
    write(*,'(A)') 'Please close and try again. Press Enter to exit.'
    read(*,'()')
    stop
  end if
Sorry for the inconvenience but I do not like to assign values such as (mean of ratings) ± 800 for scores of 0% and 100%.

Regards from Spain.

Ajedrecista.
User avatar
Ajedrecista
Posts: 2114
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Update of Probabilities_in_a_trinomial_distribution.

Post by Ajedrecista »

Hello:

I have updated my programme Probabilities_in_a_trinomial_distribution. The change can be seen in the output of Summary_of_probabilities.txt file: there is now an approximated graphical representation of the probabilities, which helps to see them at a quick glance. This feature grew the size of the executable from 36 KB to 49 KB but I have not measure a slowdown. The big increase of size is due to the poor programming trick I used: add a lot of if and else if statements (81 for being more exact), one for each case. I briefly searched for a more elegant solution but I did not find anything... this is the reason of this trick.

I have uploaded again the updated RAR file to Dropbox; the link is the same as before but the size is slightly bigger. Anyway, here is the link:

Six_Fortran_95_tools.rar (685.48 KB)

I took a fast look to CCRL 40/40 complete list: I saw Houdini 3 x64 (1 CPU) with a rating of 3180, while Komodo 5 x64 had a rating of 3123 (I am not considering error bars). They had a draw ratio of more less 44% in a direct match between them.

If there is a match with 150 games, 44% of probability of a draw in a single game and an Elo difference of 57 Elo, here is an example of the new output:

Code: Select all

Probabilities_in_a_trinomial_distribution, ® 2013.

--------------------------------------------------------------------
Probabilities of all possible scores in a match between two engines.
--------------------------------------------------------------------

Write down the number of games of the match (from 2 up to 150):

150

Write down the engines rating difference (between -800 Elo and 800 Elo).
Elo(first player) - Elo(second player):

57

Write down the probability of a draw (%) between 0.0001 % and 83.7396 %

44

Write down the clock rate of the CPU (in GHz), only for timing the elapsed time of the calculations:

3

End of the calculations. Approximated time spent in calculations:  532 ms.

The results will be saved into two different Notepads, at the same path of this programme.

The results have been successfully saved into two files:

     Probabilities.txt
     Summary_of_probabilities.txt

Approximated total elapsed time:  2302 ms.

Thanks for using Probabilities_in_a_trinomial_distribution. Press Enter to exit.

Code: Select all

Probabilities for a match of 150 games (rounded up to 0.0001%):
 
Rating difference (rounded up to 0.01 Elo):   57.00 Elo.
 
Probability of a win  = W ~ 36.1301 %
Probability of a draw = D ~ 44.0000 %
Probability of a lose = L ~ 19.8699 %
 
=====================================
 
Points:    Probabilities (%):                           Approximated graphical representation:
 
  0.0            0.0000             
  0.5            0.0000             
  1.0            0.0000             
  1.5            0.0000             
  2.0            0.0000             
  2.5            0.0000             
  3.0            0.0000             
  3.5            0.0000             
  4.0            0.0000             
  4.5            0.0000             
  5.0            0.0000             
  5.5            0.0000             
  6.0            0.0000             
  6.5            0.0000             
  7.0            0.0000             
  7.5            0.0000             
  8.0            0.0000             
  8.5            0.0000             
  9.0            0.0000             
  9.5            0.0000             
 10.0            0.0000             
 10.5            0.0000             
 11.0            0.0000             
 11.5            0.0000             
 12.0            0.0000             
 12.5            0.0000             
 13.0            0.0000             
 13.5            0.0000             
 14.0            0.0000             
 14.5            0.0000             
 15.0            0.0000             
 15.5            0.0000             
 16.0            0.0000             
 16.5            0.0000             
 17.0            0.0000             
 17.5            0.0000             
 18.0            0.0000             
 18.5            0.0000             
 19.0            0.0000             
 19.5            0.0000             
 20.0            0.0000             
 20.5            0.0000             
 21.0            0.0000             
 21.5            0.0000             
 22.0            0.0000             
 22.5            0.0000             
 23.0            0.0000             
 23.5            0.0000             
 24.0            0.0000             
 24.5            0.0000             
 25.0            0.0000             
 25.5            0.0000             
 26.0            0.0000             
 26.5            0.0000             
 27.0            0.0000             
 27.5            0.0000             
 28.0            0.0000             
 28.5            0.0000             
 29.0            0.0000             
 29.5            0.0000             
 30.0            0.0000             
 30.5            0.0000             
 31.0            0.0000             
 31.5            0.0000             
 32.0            0.0000             
 32.5            0.0000             
 33.0            0.0000             
 33.5            0.0000             
 34.0            0.0000             
 34.5            0.0000             
 35.0            0.0000             
 35.5            0.0000             
 36.0            0.0000             
 36.5            0.0000             
 37.0            0.0000             
 37.5            0.0000             
 38.0            0.0000             
 38.5            0.0000             
 39.0            0.0000             
 39.5            0.0000             
 40.0            0.0000             
 40.5            0.0000             
 41.0            0.0000             
 41.5            0.0000             
 42.0            0.0000             
 42.5            0.0000             
 43.0            0.0000             
 43.5            0.0000             
 44.0            0.0000             
 44.5            0.0000             
 45.0            0.0000             
 45.5            0.0000             
 46.0            0.0000             
 46.5            0.0000             
 47.0            0.0000             
 47.5            0.0000             
 48.0            0.0000             
 48.5            0.0000             
 49.0            0.0000             
 49.5            0.0000             
 50.0            0.0000             
 50.5            0.0000             
 51.0            0.0000             
 51.5            0.0000             
 52.0            0.0000             
 52.5            0.0000             
 53.0            0.0000             
 53.5            0.0000             
 54.0            0.0000             
 54.5            0.0000             
 55.0            0.0000             
 55.5            0.0000             
 56.0            0.0000             
 56.5            0.0000             
 57.0            0.0000             
 57.5            0.0000             
 58.0            0.0000             
 58.5            0.0000             
 59.0            0.0000             
 59.5            0.0000             
 60.0            0.0000             
 60.5            0.0000             
 61.0            0.0000             
 61.5            0.0000             
 62.0            0.0000             
 62.5            0.0000             
 63.0            0.0000             
 63.5            0.0000             
 64.0            0.0000             
 64.5            0.0000             
 65.0            0.0000             
 65.5            0.0000             
 66.0            0.0001             
 66.5            0.0001             
 67.0            0.0002             
 67.5            0.0003             
 68.0            0.0005             
 68.5            0.0008             
 69.0            0.0013             
 69.5            0.0020             
 70.0            0.0031             
 70.5            0.0047             
 71.0            0.0070             
 71.5            0.0103             
 72.0            0.0151             
 72.5            0.0217             
 73.0            0.0309            -
 73.5            0.0435            -
 74.0            0.0605            -
 74.5            0.0830            -
 75.0            0.1126            --
 75.5            0.1510            ---
 76.0            0.1999            ----
 76.5            0.2615            -----
 77.0            0.3380            ------
 77.5            0.4317            --------
 78.0            0.5446            ----------
 78.5            0.6788            ------------
 79.0            0.8359            ---------------
 79.5            1.0170            ------------------
 80.0            1.2224            ----------------------
 80.5            1.4514            --------------------------
 81.0            1.7026            -------------------------------
 81.5            1.9730            -----------------------------------
 82.0            2.2587            -----------------------------------------
 82.5            2.5544            ----------------------------------------------
 83.0            2.8537            ---------------------------------------------------
 83.5            3.1493            ---------------------------------------------------------
 84.0            3.4332            --------------------------------------------------------------
 84.5            3.6970            ------------------------------------------------------------------
 85.0            3.9323            -----------------------------------------------------------------------
 85.5            4.1314            --------------------------------------------------------------------------
 86.0            4.2873            -----------------------------------------------------------------------------
 86.5            4.3944            -------------------------------------------------------------------------------
 87.0            4.4486            --------------------------------------------------------------------------------
 87.5            4.4478            --------------------------------------------------------------------------------
 88.0            4.3919            -------------------------------------------------------------------------------
 88.5            4.2830            -----------------------------------------------------------------------------
 89.0            4.1247            --------------------------------------------------------------------------
 89.5            3.9227            -----------------------------------------------------------------------
 90.0            3.6839            ------------------------------------------------------------------
 90.5            3.4162            -------------------------------------------------------------
 91.0            3.1281            --------------------------------------------------------
 91.5            2.8281            ---------------------------------------------------
 92.0            2.5245            ---------------------------------------------
 92.5            2.2249            ----------------------------------------
 93.0            1.9358            -----------------------------------
 93.5            1.6627            ------------------------------
 94.0            1.4098            -------------------------
 94.5            1.1799            ---------------------
 95.0            0.9748            ------------------
 95.5            0.7948            --------------
 96.0            0.6396            ------------
 96.5            0.5080            ---------
 97.0            0.3981            -------
 97.5            0.3079            ------
 98.0            0.2350            ----
 98.5            0.1769            ---
 99.0            0.1314            --
 99.5            0.0963            --
100.0            0.0696            -
100.5            0.0496            -
101.0            0.0349            -
101.5            0.0242             
102.0            0.0166             
102.5            0.0112             
103.0            0.0074             
103.5            0.0049             
104.0            0.0032             
104.5            0.0020             
105.0            0.0013             
105.5            0.0008             
106.0            0.0005             
106.5            0.0003             
107.0            0.0002             
107.5            0.0001             
108.0            0.0001             
108.5            0.0000             
109.0            0.0000             
109.5            0.0000             
110.0            0.0000             
110.5            0.0000             
111.0            0.0000             
111.5            0.0000             
112.0            0.0000             
112.5            0.0000             
113.0            0.0000             
113.5            0.0000             
114.0            0.0000             
114.5            0.0000             
115.0            0.0000             
115.5            0.0000             
116.0            0.0000             
116.5            0.0000             
117.0            0.0000             
117.5            0.0000             
118.0            0.0000             
118.5            0.0000             
119.0            0.0000             
119.5            0.0000             
120.0            0.0000             
120.5            0.0000             
121.0            0.0000             
121.5            0.0000             
122.0            0.0000             
122.5            0.0000             
123.0            0.0000             
123.5            0.0000             
124.0            0.0000             
124.5            0.0000             
125.0            0.0000             
125.5            0.0000             
126.0            0.0000             
126.5            0.0000             
127.0            0.0000             
127.5            0.0000             
128.0            0.0000             
128.5            0.0000             
129.0            0.0000             
129.5            0.0000             
130.0            0.0000             
130.5            0.0000             
131.0            0.0000             
131.5            0.0000             
132.0            0.0000             
132.5            0.0000             
133.0            0.0000             
133.5            0.0000             
134.0            0.0000             
134.5            0.0000             
135.0            0.0000             
135.5            0.0000             
136.0            0.0000             
136.5            0.0000             
137.0            0.0000             
137.5            0.0000             
138.0            0.0000             
138.5            0.0000             
139.0            0.0000             
139.5            0.0000             
140.0            0.0000             
140.5            0.0000             
141.0            0.0000             
141.5            0.0000             
142.0            0.0000             
142.5            0.0000             
143.0            0.0000             
143.5            0.0000             
144.0            0.0000             
144.5            0.0000             
145.0            0.0000             
145.5            0.0000             
146.0            0.0000             
146.5            0.0000             
147.0            0.0000             
147.5            0.0000             
148.0            0.0000             
148.5            0.0000             
149.0            0.0000             
149.5            0.0000             
150.0            0.0000             
 
==============================================================
 
                           SUMMARY:
 
 Probability that the first player wins the match ~  99.6021 %
                      Probability of a tied match ~   0.1126 %
Probability that the second player wins the match ~   0.2853 %
Houdini is the clear favourite in this hipothetic match under the assumptions I wrote before. The hyphens provide the new info: with 150 games, it looks like a normal distribution, so it should mean that my programme is correct. The mode of the distribution is rescaled to 80 hyphens, then the rest of values are resized according to that. Some screen resolutions (as mine) will show some hyphen bars in two lines instead of one; luckily, the rest of people will see them as they are, and will apreciate the bell-shaped form of this density function. The output notepad shows it correct, as expected.

Regards from Spain.

Ajedrecista.
User avatar
Ajedrecista
Posts: 2114
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

New update of Probabilities_in_a_trinomial_distribution.

Post by Ajedrecista »

Hello:

I found a better idea for naming the arrays and I reduced dimensions, so now this programme is lighter in the sense of used RAM; I also got rid of intermediate calculations.

Just for comparison, my previous release accepted a maximum of 150 games and the used RAM was almost 800 MB in my PC, verified with the task manager; now, Probabilities_in_a_trinomial_distribution accepts a maximum of 1000 games and the used RAM is around 160 MB (verified with the task manager again).

But this great improvement come with a cost: the programme is slower for the same number of games. Just an example: computing 150 games took around 0.5 seconds in my PC with my previous release; now they take around 40 or 41 seconds. I do not know why, but the maximum number of games supported certainly has an importance in the poor way I programme: if I set 150 games as the maximum in the compile, then compute 150 games takes 0.4 seconds more less! But I think that the bonus of compute up to 1000 games is enough good. After several trials with 1000 games in my PC, the time of calculations is around 270 or 280 seconds, while the time of writing that info lasts a minute more less. This programme is single core, 32-bit, so faster calculations can be reached with a faster CPU but it can not take advantage of SMP and/or 64-bit executables... anyway, I think that it is worth because it can calculate exact trinomial distributions (except rounding errors, of course!) up to a considerable number of games. Indeed, I can raise this limit without problems up to 2000 games and even more inside the source code, but time of calculations also raises.

Six_Fortran_95_tools.rar (685.38 KB)

------------------------

I have seen weird tests many times in other chess fora, consisting in ten games of 1+0 (minutes) of time control, then drawing absolute conclusions. The tested engines were the same but with very small changes, for example (just exaggerating) testing '(Bishop pair) = 0.46' against '(Bishop pair) = 0.47'. Supposing 0 Elo difference and 60% of probability of a draw in a single game (something usual in self testing, as SF shows in its distributed testing framework), this is what I get:

Code: Select all

Probabilities_in_a_trinomial_distribution, ® 2013.

--------------------------------------------------------------------
Probabilities of all possible scores in a match between two engines.
--------------------------------------------------------------------

Write down the number of games of the match (from 2 up to 1000):

10

Write down the engines rating difference (between -800 Elo and 800 Elo).
Elo(first player) - Elo(second player):

0

Write down the probability of a draw (%) between 0.0001 % and 99.9999 %

60

Write down the clock rate of the CPU (in GHz), only for timing the elapsed time of the calculations:

3

Calculating, please wait.

50% of the calculations are done; approximated elapsed time:   1.65 seconds.

End of the calculations.
Approximated time spent in calculations:   2.89 seconds.

The results will be saved into two different Notepads, at the same path of this
programme.

The results have been successfully saved into two files:

     Probabilities.txt
     Summary_of_probabilities.txt

Approximated total elapsed time:   2.96 seconds.

Thanks for using Probabilities_in_a_trinomial_distribution. Press Enter to exit.

Code: Select all

Probabilities for a match of   10 games (rounded up to 0.0001 %):
 
Rating difference (rounded up to 0.01 Elo):    0.00 Elo.
 
Probability of a win  = W ~ 20.0000 %
Probability of a draw = D ~ 60.0000 %
Probability of a lose = L ~ 20.0000 %
 
==============================================================================================
 
Points:    Probabilities (%):                           Approximated graphical representation:
 
   0.0            0.0000 
   0.5            0.0003 
   1.0            0.0042 
   1.5            0.0359 
   2.0            0.2078            -
   2.5            0.8704            ----
   3.0            2.7301            -----------
   3.5            6.5452            --------------------------
   4.0           12.1410            -------------------------------------------------
   4.5           17.5482            -----------------------------------------------------------------------
   5.0           19.8337            --------------------------------------------------------------------------------
   5.5           17.5482            -----------------------------------------------------------------------
   6.0           12.1410            -------------------------------------------------
   6.5            6.5452            --------------------------
   7.0            2.7301            -----------
   7.5            0.8704            ----
   8.0            0.2078            -
   8.5            0.0359 
   9.0            0.0042 
   9.5            0.0003 
  10.0            0.0000 
 
==============================================================
 
                           SUMMARY:
 
 Probability that the first player wins the match ~  40.0832 %
                      Probability of a tied match ~  19.8337 %
Probability that the second player wins the match ~  40.0832 %
 
--------------------------------------------------------------
 
 Prob.(first player wins) + 0.5*Prob.(tied match) ~  50.0000 %
Prob.(second player wins) + 0.5*Prob.(tied match) ~  50.0000 %
Then, if the result is either 4-6 or 6-4 (around 24.3% of probability under my assumptions), they claim an incredible 70 Elo improvement without doubts... Sigh.

My programme can be easily optimized (I am sure of it) but I do not know how... anyway, I think it is not horrible. Have a nice day!

Regards from Spain.

Ajedrecista.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: New update of Probabilities_in_a_trinomial_distribution.

Post by Evert »

Ajedrecista wrote:But this great improvement come with a cost: the programme is slower for the same number of games. Just an example: computing 150 games took around 0.5 seconds in my PC with my previous release; now they take around 40 or 41 seconds. I do not know why, but the maximum number of games supported certainly has an importance in the poor way I programme: if I set 150 games as the maximum in the compile, then compute 150 games takes 0.4 seconds more less! But I think that the bonus of compute up to 1000 games is enough good.
Just a few quick suggestions after looking at the code briefly.
The main one is to flip the order of array indices. Currently you have thinks like

Code: Select all

integer :: wins(0:2*n, 0:2*n)

do i = 1, i_max/2
    do j = 0, int(i/2)
        wins(i,j) = ...
which is the wrong way round: the first index is continuous in memory, the second one skips, in this case, 2000 integers between each element (NB: this is the opposite to what you would have in C). I was sped up a program by more than a factor of 10 by correcting a similar issue.

The second suggestion is to make more use of array operations where possible (ie, as opposed to writing the loops explicitly). I've seen the compiler produce better code if you do.

Finally, get rid of some of the gotos. :P They not only make it a bit hard to follow what is going on, but again the compiler may be able to generate better code if you use more high-level constructs.

EDIT: by the way, neither ifort nor gfortran will compile the source for me... ifort says something incoherent about ipo (Interprocedural OPtimisations) not being able to recognise the file format, followed by a claim that the architecture is wrong, followed by a complaint that main is not found. gfortran chokes on "real(kind=3)" and complains that "kind 3" is not supported.
It is possible to write portable code in FORTRAN, but some language features seem designed to make this as hard as possible...
User avatar
Ajedrecista
Posts: 2114
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: New update of Probabilities_in_a_trinomial_distribution.

Post by Ajedrecista »

Hi Evert:
Evert wrote:
Ajedrecista wrote:But this great improvement come with a cost: the programme is slower for the same number of games. Just an example: computing 150 games took around 0.5 seconds in my PC with my previous release; now they take around 40 or 41 seconds. I do not know why, but the maximum number of games supported certainly has an importance in the poor way I programme: if I set 150 games as the maximum in the compile, then compute 150 games takes 0.4 seconds more less! But I think that the bonus of compute up to 1000 games is enough good.
Just a few quick suggestions after looking at the code briefly.
The main one is to flip the order of array indices. Currently you have thinks like

Code: Select all

integer :: wins(0:2*n, 0:2*n)

do i = 1, i_max/2
    do j = 0, int(i/2)
        wins(i,j) = ...
which is the wrong way round: the first index is continuous in memory, the second one skips, in this case, 2000 integers between each element (NB: this is the opposite to what you would have in C). I was sped up a program by more than a factor of 10 by correcting a similar issue.

The second suggestion is to make more use of array operations where possible (ie, as opposed to writing the loops explicitly). I've seen the compiler produce better code if you do.

Finally, get rid of some of the gotos. :P They not only make it a bit hard to follow what is going on, but again the compiler may be able to generate better code if you use more high-level constructs.

EDIT: by the way, neither ifort nor gfortran will compile the source for me... ifort says something incoherent about ipo (Interprocedural OPtimisations) not being able to recognise the file format, followed by a claim that the architecture is wrong, followed by a complaint that main is not found. gfortran chokes on "real(kind=3)" and complains that "kind 3" is not supported.
It is possible to write portable code in FORTRAN, but some language features seem designed to make this as hard as possible...
Thanks for your interest!

I think that C and Fortran do not work in the same way with double do loops. I have read that doing the wrong way is three times slower than the correct way. I thought that I did things well, but of course I can be wrong. Maybe I will take a look on this one.

Regarding your second suggestion: I have to take a look... not sure what you mean, but remember that I am not a programmer!

Goto issue: well, I am not so smart to get rid of them. I know that true and elegant programmers do not like it, but again I am not a true programmer.

I use Plato IDE (Silverfrost) for compile my sources: real(KIND=3) is a kind of extended double precission that is not recognised by gfortran. Of course real should solve the issue.

I have no time now, but I will try to take a look to your suggestions. I do not promise anything. Thanks again for your interest!

Regards from Spain.

Ajedrecista.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: New update of Probabilities_in_a_trinomial_distribution.

Post by Evert »

Ajedrecista wrote:I think that C and Fortran do not work in the same way with double do loops.
Correct. It's very confusing (especially if you switch between the two languages).
I have read that doing the wrong way is three times slower than the correct way.
It depends on the application. As I said, I've seen a case where it slowed things down by a factor of 10 (or worse), but I doubt it'll be that bad for you.
I thought that I did things well, but of course I can be wrong. Maybe I will take a look on this one.
Don't worry, I've messed it up on more than one occasion.
Regarding your second suggestion: I have to take a look... not sure what you mean, but remember that I am not a programmer!
Ok. What I meant is that in FORTRAN you can often write operations on arrays in the same way as operations on scalars, for instance

Code: Select all

x = (a*b + c) / 3
where x, a, b and c can all be arrays (they must be "conforming arrays", meaning they have the same dimensions, for obvious reasons). The compiler than takes care to write the loop for you (or do something more clever if it can).
I use Plato IDE (Silverfrost) for compile my sources: real(KIND=3) is a kind of extended double precission that is not recognised by gfortran. Of course real should solve the issue.
The thing is, "kind=integer" is not portable across different compilers since the standard doesn't specify what number corresponds to what type of integer. There are intrinsics for getting the real kind that has a range of such-and-so that I don't remember off the top of my head. Either way, if you don't need more than double precision, I'd suggest not using more than double precision. While double is as fast as single on modern CPUs (with one caveat: if you have a large array, it may fit in cache if it's single but not when it's double precision), that's not true for extended or quad precision. :)
I have no time now, but I will try to take a look to your suggestions. I do not promise anything. Thanks again for your interest!
No rush.