|
本帖最后由 weixing1531 于 2014-6-24 21:00 编辑
小组共4只球队 单循环共6场比赛(主客场双循环共12场比赛) 小组积分前两名出线
两大假定:
1.各队胜、平、负概率均等,均为1/3,不模拟进球
2.积分相同情况下,抽签决定出线
运行环境: Win7 i3 CVF6.6C
世界杯小组出线概率模拟结果:
欧冠主客场双循环小组出线概率模拟结果:
源程序:
[Fortran] 纯文本查看 复制代码 05 | integer ( selected_int_kind ( 2 ) ) , parameter :: IxB = selected_int_kind ( 9 ) |
06 | integer ( IxB ) , parameter :: DP = kind ( 1.0e0 ) |
15 | integer ( IxB ) , parameter :: NCSV = 10 |
16 | integer ( IxB ) , parameter :: WIN = 3 , DRAW = 1 , LOSS = 0 |
17 | integer ( IxB ) , parameter :: TEAMS = 4 , TEAMSCORE = 3 , CYCLING = 2 , NUM = 21000000 _IxB |
18 | integer ( IxB ) , allocatable :: matrix ( : , : ) , score ( : ) , first ( : ) , second ( : ) , firstLoc ( : ) , secondLoc ( : ) |
19 | integer ( IxB ) :: i , j , k , n , point , total |
21 | open ( NCSV , file = '计算结果.csv' ) |
22 | allocate ( matrix ( TEAMS , TEAMS ) , score ( TEAMS ) , first ( NUM ) , second ( NUM ) , firstLoc ( NUM ) , secondLoc ( NUM ) ) |
35 | matrix ( i , j ) = matrix ( i , j ) + point |
36 | if ( point == DRAW ) matrix ( j , i ) = matrix ( j , i ) + point |
37 | if ( point == LOSS ) matrix ( j , i ) = matrix ( j , i ) + WIN |
46 | score = ( / ( sum ( matrix ( : , j ) ) , j = 1 , TEAMS ) / ) |
47 | total = total + count ( score == TEAMSCORE ) |
48 | first ( k ) = maxval ( score ) |
49 | firstLoc ( k ) = maxloc ( score , 1 ) |
54 | second ( k ) = maxval ( score ) |
55 | secondLoc ( k ) = maxloc ( score , 1 ) |
60 | write ( NCSV , "(a,5(',',a))" ) '球队积分' , '头名次数' , '次名次数' , '总次数' , '出线概率' , '头名概率' |
61 | write ( NCSV , "(4(i8,','),f9.7,',',f9.7)" ) TEAMSCORE , count ( first == TEAMSCORE ) , count ( second == TEAMSCORE ) , total , dble ( count ( first == TEAMSCORE ) + count ( second == TEAMSCORE ) ) / dble ( total ) , dble ( count ( first == TEAMSCORE ) ) / dble ( total ) |
63 | write ( * , * ) '程序结束,按任意键退出!' |
67 | subroutine CalPoint ( point ) |
68 | integer ( IxB ) , intent ( out ) :: point |
70 | real ( DP ) , parameter :: R 1 = 0.33333333e0 , R 2 = 0.66666666e0 |
72 | CALL RANDOM_NUMBER ( harvest ) |
76 | else if ( harvest <= R 2 ) then |
football.zip
(543.31 KB, 下载次数: 0)
|
评分
-
查看全部评分
|