저작자표시 - 비영리 - 변경금지 2.0 대한민국 이용자는아래의조건을따르는경우에한하여자유롭게 이저작물을복제, 배포, 전송, 전시, 공연및방송할수있습니다. 다음과같은조건을따라야합니다 : 저작자표시. 귀하는원저작자를표시하여야합니다. 비영리. 귀하는이저작물을영리목적으로이용할수없습니다. 변경금지. 귀하는이저작물을개작, 변형또는가공할수없습니다. 귀하는, 이저작물의재이용이나배포의경우, 이저작물에적용된이용허락조건을명확하게나타내어야합니다. 저작권자로부터별도의허가를받으면이러한조건들은적용되지않습니다. 저작권법에따른이용자의권리는위의내용에의하여영향을받지않습니다. 이것은이용허락규약 (Legal Code) 을이해하기쉽게요약한것입니다. Disclaimer
도시계획학박사학위논문 자전거차두시간과차량회피행태기반 자전거도로주행안전성연구 년 월 서울대학교환경대학원 환경계획학과교통학전공 전우훈
자전거차두시간과차량회피행태기반 자전거도로주행안전성연구 지도교수이영인 이논문을도시계획학박사학위논문으로제출함 년 월 서울대학교환경대학원 환경계획학과교통학전공 전우훈 전우훈의박사학위논문을인준함 년 월 위원장 부위원장 인 인 위원 인 위원 인 위원 인
- ii -
~
- i -
- ii -
- iii -
- iv -
- v -
- 1 -
- 2 -
- 3 -
- 4 -
- 5 -
~ - 6 -
< 표 1-1> 자전거교통사고통계 ( 경찰청, 2015) 그림 연구의공간적범위및내용 - 7 -
그림 연구의내용적범위에따른수행절차 - 8 -
- 9 -
그림 연구의수행체계 - 10 -
- 11 -
- 12 -
- 13 -
- 14 -
< 표 2-1> 차두시간분포모형의선행연구고찰결과 - 15 -
- 16 -
- 17 -
< 표 2-2> 자전거도로용량의선행연구고찰결과 - 18 -
- 19 -
< 표 2-3> 자동차의자전거회피행태의선행연구고찰결과 - 20 -
- 21 -
- 22 -
- 23 -
평균차두시간 초 평균교통류율 - 24 -
그림 시간 거리관계에서의차두시간개념 - 25 -
- 26 -
- 27 -
- 28 -
~ ~ ~ ~ - 29 -
< 표 3-1> 피어슨 Ⅲ 분포모형의분류에따른수식 (May, 1990) - 30 -
- 31 -
그림 차두시간데이터수집전경 - 32 -
그림 차두시간측정방법 그림 차두시간분석프로그램 - 33 -
그림 차두시간모의실험개요 - 34 -
그림 차두시간모의실험전경 - 35 -
< 표 3-2> 모의실험의주행속도에따른차두시간 - 36 -
그림 차두시간과교통량 우측 관측 그림 차두시간과교통량 좌측 관측 - 37 -
그림 차두시간과교통량 양방향 관측 - 38 -
χ - 39 -
< 표 3-3> 차두시간데이터의기초통계량 그림 관측치와예측치의비교 좌측 낮은교통량 - 40 -
< 표 3-4> 차두시간관측치와이론치의데이터비교 ( 좌측, 낮은교통량 ) 그림 관측치와예측치의비교 좌측 높은교통량 - 41 -
< 표 3-5> 차두시간관측치와이론치의데이터비교 ( 좌측, 높은교통량 ) 그림 관측치와예측치의비교 우측 낮은교통량 - 42 -
< 표 3-6> 차두시간관측치와이론치의데이터비교 ( 우측, 낮은교통량 ) 그림 관측치와예측치의비교 우측 높은교통량 - 43 -
< 표 3-7> 차두시간관측치와이론치의데이터비교 ( 우측, 높은교통량 ) - 44 -
< 표 3-8> 분포에따른통계검정결과 ( 모형선정단계 ) - 45 -
그림 전이값에따른통계검정결과 - 46 -
- 47 -
그림 관측치와예측치의비교 평가 좌측 낮은교통량 < 표 3-10> 차두시간관측치와이론치의데이터비교ㆍ평가 ( 좌측, 낮은교통량 ) - 48 -
그림 관측치와예측치의비교 평가 좌측 높은교통량 < 표 3-11> 차두시간관측치와이론치의데이터비교ㆍ평가 ( 좌측, 높은교통량 ) - 49 -
그림 관측치와예측치의비교 평가 우측 낮은교통량 < 표 3-12> 차두시간관측치와이론치의데이터비교ㆍ평가 ( 우측, 낮은교통량 ) - 50 -
그림 관측치와예측치의비교 평가 우측 높은교통량 < 표 3-13> 차두시간관측치와이론치의데이터비교ㆍ평가 ( 우측, 높은교통량 ) - 51 -
< 표 3-14> 분포에따른통계검정결과 ( 모형적용및평가단계 ) - 52 -
- 53 -
- 54 -
- 55 -
- 56 -
- 57 -
- 58 -
μ σ μ μ - 59 -
- 60 -
그림 자전거교통류군측정전경 그림 교통류군의차두시간측정방법 - 61 -
그림 차두시간분포 한강 - 62 -
그림 차두시간분포 안양천 - 63 -
그림 차두시간분포 전체 < 표 3-15> 자전거도로차두시간에따른용량 - 64 -
- 65 -
- 66 -
- 67 -
- 68 -
- 69 -
그림 자동차와자전거의이격거리규정 그림 미국주 별이격거리규정 - 70 -
~ - 71 -
그림 회피행태의현장실험위치 출처 구글맵 ~ - 72 -
그림 이격거리산출을위한노면마킹방법 그림 이격거리산출을위한노면마킹형태 - 73 -
그림 통행방법에따른실험시나리오 그림 실험구간시 종점및촬영구간 출처 구글맵 - 74 -
< 표 4-1> 데이터수집및적정성판단 파일번호 1 시간구분 분석대상판단 08:34 ~ 08:47 13min O 비고 2 08:47 ~ 09:00 13min O 3 09:00 ~ 09:13 13min O 4 09:13 ~ 09:26 13min O 5 09:26 ~ 09:39 13min O 6 09:39 ~ 09:52 13min O 7 09:52 ~ 10:05 13min O 오전 8 10:05 ~ 10:18 13min O 9 10:18 ~ 10:31 13min O 10 10:31 ~ 10:44 13min O 11 10:44 ~ 10:57 - X 12 10:57 ~ 11:10 - X 13 11:10 ~ 11:23 - X 풍압으로인해 구간확인불가 14 11:23 ~ 11:36 - X - 75 -
< 표 4-1> 데이터수집및적정성판단 ( 계속 ) 파일번호 15 시간구분 분석대상판단 비고 13:30 ~ 13:43 - X 카메라재설치 16 13:43 ~ 13:56 13min O 17 13:56 ~ 14:09 13min O 18 14:09 ~ 14:22 13min O 19 14:22 ~ 14:35 - X 샘플부족 20 14:35 ~ 14:48 13min O 21 14:48 ~ 15:01 13min O 오후 22 15:01 ~ 15:14 13min O 23 15:14 ~ 15:27 13min O 24 15:27 ~ 15:40 - X 샘플부족 25 15:40 ~ 15:53 13min O 26 15:53 ~ 16:06 - X 27 16:06 ~ 16:19 - X 28 16:19 ~ 16:32 - X 음영등으로인한 구간마킹확인 어려움 총영상자료분석대상시간합계 3h 56min - ~ - 76 -
그림 구간별영상자료코딩방법 그림 분석개체별영상자료입력방법 - 77 -
< 표 4-2> 분석유효데이터수 구분상행하행합계 영상코딩전체샘플수 61 80 141 그림 이격거리그래프의중앙좌표변환 - 78 -
< 표 4-3> 추월지점기준 Data Set의개수 구분 구간 개수 -100 47-90 59-80 63-70 79 추월전 -60 84-50 89-40 101-30 114-20 131-10 141 추월지점 0 141 +10 141 +20 133 +30 126 +40 120 추월후 +50 114 +60 106 +70 94 +80 82 +90 78 +100 62-79 -
그림 자동차의이격궤적 전체 상행 하행 - 80 -
< 표 4-4> 자전거추월에따른이격거리 횡방향이격거리 (m) 구분 구간 상행 하행 전체 평균 표준편차 평균 표준편차 평균 표준편차 -100 1.02 0.42 1.13 0.25 1.07 0.35-90 1.04 0.41 1.13 0.25 1.08 0.34-80 0.99 0.40 1.10 0.28 1.04 0.35-70 0.95 0.41 1.12 0.33 1.04 0.38 추월전 -60 0.95 0.40 1.12 0.28 1.04 0.35-50 1.03 0.42 1.12 0.28 1.08 0.35-40 1.11 0.42 1.21 0.28 1.16 0.36-30 1.26 0.38 1.30 0.39 1.28 0.38-20 1.40 0.38 1.45 0.39 1.43 0.38-10 1.57 0.40 1.57 0.38 1.57 0.39 추월지점 0 1.53 0.41 1.62 0.40 1.58 0.40 +10 1.51 0.44 1.61 0.39 1.57 0.41 +20 1.36 0.44 1.53 0.39 1.46 0.42 +30 1.22 0.43 1.41 0.35 1.33 0.39 +40 1.11 0.41 1.25 0.35 1.19 0.39 추월후 +50 0.97 0.39 1.17 0.35 1.08 0.38 +60 0.88 0.34 1.05 0.31 0.98 0.33 +70 0.78 0.34 0.95 0.34 0.88 0.35 +80 0.78 0.33 0.86 0.34 0.83 0.34 +90 0.80 0.34 0.87 0.32 0.84 0.33 +100 0.85 0.30 0.85 0.31 0.85 0.31-81 -
μ 그림 정규분포형태 신뢰수준 μ ± μ - 82 -
μ σ σ μ μ 신뢰수준 신뢰수준 - 83 -
< 표 4-5> 신뢰수준에따른안전이격거리의신뢰구간 신뢰수준 (Level of Confidence) 이격거리하한치 (m) 이격거리상한치 (m) 95% 1.51 1.65 99% 1.49 1.67-84 -
- 85 -
그림 길어깨적정폭산정개념 - 86 -
그림 추월시작점과추월종료점의개념 - 87 -
< 표 4-6> 지점별횡방향이격거리변화량 구분 구간 변화량 ( 기울기 ) 증감 -100 ~ -90 0.001 0.009-90 ~ -80-0.004-0.005-80 ~ -70-0.001 0.003-70 ~ -60 0.000 0.001 추월전 -60 ~ -50 0.004 0.003-50 ~ -40 0.008 0.005-40 ~ -30 0.012 0.004-30 ~ -20 0.014 0.002-20 ~ -10 0.014 0.000-10 ~ 0 0.001-0.013 0 ~ 10-0.001-0.003 10 ~ 20-0.011-0.009 20 ~ 30-0.013-0.003 30 ~ 40-0.014-0.001 추월후 40 ~ 50-0.011 0.003 50 ~ 60-0.010 0.000 60 ~ 70-0.010 0.000 70 ~ 80-0.005 0.005 80 ~ 90 0.001 0.006 90 ~ 100 0.001-0.001-88 -
그림 추월영향권구간선정 - 89 -
< 표 4-7> 일반주행의지점별횡방향이격거리 구분 횡방향이격거리 (m) 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 샘플 127 117 103 86 68 45 30 15 0 5 22 44 64 78 90 103 상행평균 0.85 0.86 0.92 0.95 0.97 0.98 0.98 1.03 0.00 0.46 0.75 0.75 0.75 0.77 0.77 0.75 표준 0.33 0.34 0.34 0.37 0.38 0.40 0.42 0.30 0.00 0.05 0.40 0.34 0.35 0.37 0.38 0.37 편차 샘플 118 114 93 73 56 45 28 17 3 9 25 49 70 100 115 128 하행평균 1.02 1.02 1.04 1.03 1.06 1.08 1.16 1.13 0.87 0.87 0.71 0.71 0.70 0.77 0.83 0.85 표준 0.38 0.38 0.38 0.40 0.39 0.38 0.35 0.34 0.21 0.31 0.28 0.30 0.30 0.32 0.33 0.34 편차 샘플 245 231 196 159 124 90 58 32 3 14 47 93 134 178 205 231 전체평균 0.93 0.94 0.98 0.99 1.01 1.03 1.07 1.08 0.43 0.66 0.73 0.73 0.73 0.77 0.80 0.80 표준 0.36 0.36 0.36 0.39 0.39 0.39 0.39 0.32 0.10 0.18 0.34 0.32 0.33 0.34 0.35 0.36 편차 - 90 -
< 표 4-8> Levene 통계검정구분 Levene 통계량 유의확률 일반주행 0.753 6 2033 0.607 추월주행 1.690 6 134 0.128-91 -
그림 일반주행지점별변화추이 - 92 -
- 93 -
그림 안전을고려한최소길어깨폭산정식 < 표 4-9> 안전을고려한최소길어깨폭 ( 단위 : m) 최소길어깨폭 ( ) 자전거폭 ( ) 회피행태 이격거리 ( ) 일반행태 이격거리 ( ) 2.08 0.7 1.58 0.89-94 -
~ - 95 -
- 96 -
- 97 -
- 98 -
- 99 -
- 100 -
- 101 -
- 102 -
- 103 -
- 104 -
- 105 -
# Working directory setting getwd() setwd( "c:/users/ywint/documents/pgm_r/bicycles/capacity" ) # office PC # Read data data_a <- read.csv( "data/anyang_sample_mean.csv" ) data_m <- read.csv( "data/mangwon_sample_mean.csv" ) data_t <- read.csv( "data/total_sample_mean.csv" ) x <- seq( -4, 4, length = 100 ) hist( data_a$th, density=20, breaks= c(0.2*0:15), prob=true, xlab="time headway (sec)", ylim=c(0, 1.5), col = "darkturquoise", main="sample Mean Distribution of Bicycle Time Headways\n(Anyang)") curve( dnorm(x, mean=mean( data_a$th ), sd= sd( data_a$th) ), lty = 1, col="firebrick2", lwd=2, add=true, yaxt="n") com <- sprintf( "Normal dist. with mean (%5.3f) and sd (%5.3f)", mean( data_a$th ), sd(data_a$th ) ) legend("top", inset=.05, c(com), - 106 -
col = c("firebrick2"), lty = c( 1 ), horiz=true) hist( data_m$th, density=20, breaks= c(0.2*0:15), prob=true, xlab="time headway (sec)", ylim=c(0, 1.5), col = "darkturquoise", main="sample Mean Distribution of Bicycle Time Headways\n(Mangwon)") curve( dnorm(x, mean=mean( data_m$th ), sd= sd( data_m$th) ), lty = 1, col="firebrick2", lwd=2, add=true, yaxt="n") com <- sprintf( "Normal dist. with mean (%5.3f) and sd (%5.3f)", mean( data_m$th ), sd(data_m$th ) ) legend("top", inset=.05, c(com), col = c("firebrick2"), lty = c( 1 ), horiz=true) hist( data_t$th, density=20, breaks= c(0.2*0:15), prob=true, xlab="time headway (sec)", ylim=c(0, 1.5), col = "darkturquoise", main="sample Mean Distribution of Bicycle Time Headways\n(Total)") curve( dnorm(x, mean=mean( data_t$th ), sd= sd( data_t$th) ), lty = 1, col="firebrick2", lwd=2, add=true, yaxt="n") - 107 -
com <- sprintf( "Normal dist. with mean (%5.3f) and sd (%5.3f)", mean( data_t$th ), sd(data_t$th ) ) legend("top", inset=.05, c(com), col = c("firebrick2"), lty = c( 1 ), horiz=true) - 108 -
1. Main.r # Package installation of Pearson distribution # install.packages( "PearsonDS" ) # Library loading of Pearson distribution library( PearsonDS ) # Working directory setting getwd() setwd( "c:/users/cwhoon/bic_final/" ) # Library call source( "Util.R" ) # Read data L1 <- read.csv( "data/01l.csv" ) L2 <- read.csv( "data/02l.csv" ) L3 <- read.csv( "data/03l.csv" ) L4 <- read.csv( "data/04l.csv" ) R1 <- read.csv( "data/01r.csv" ) R2 <- read.csv( "data/02r.csv" ) R3 <- read.csv( "data/03r.csv" ) R4 <- read.csv( "data/04r.csv" ) # Define min/max time headway MIN_TH <- 700-0.000001 MAX_TH <- 30000+0.000001-109 -
# Remove records which are too short or too long L1_filtered <- L1[L1$Time_headway_msec > MIN_TH & L1$Time_headway_msec < MAX_TH, ] L2_filtered <- L2[L2$Time_headway_msec > MIN_TH & L2$Time_headway_msec < MAX_TH, ] L3_filtered <- L3[L3$Time_headway_msec > MIN_TH & L3$Time_headway_msec < MAX_TH, ] L4_filtered <- L4[L4$Time_headway_msec > MIN_TH & L4$Time_headway_msec < MAX_TH, ] R1_filtered <- R1[R1$Time_headway_msec > MIN_TH & R1$Time_headway_msec < MAX_TH, ] R2_filtered <- R2[R2$Time_headway_msec > MIN_TH & R2$Time_headway_msec < MAX_TH, ] R3_filtered <- R3[R3$Time_headway_msec > MIN_TH & R3$Time_headway_msec < MAX_TH, ] R4_filtered <- R4[R4$Time_headway_msec > MIN_TH & R4$Time_headway_msec < MAX_TH, ] # Count traffic volume and assign the traffic level to every record L1_filtered$traffic <- 0; L1_filtered <- CalcTraffic( L1_filtered, 300000L, 40L ); L2_filtered$traffic <- 0; L2_filtered <- CalcTraffic( L2_filtered, 300000L, 40L ); L3_filtered$traffic <- 0; L3_filtered <- CalcTraffic( L3_filtered, 300000L, 40L ); L4_filtered$traffic <- 0; L4_filtered <- CalcTraffic( L4_filtered, 300000L, 40L ); R1_filtered$traffic <- 0; R1_filtered <- CalcTraffic( R1_filtered, 300000L, 40L ); R2_filtered$traffic <- 0; R2_filtered <- CalcTraffic( R2_filtered, 300000L, 40L ); R3_filtered$traffic <- 0; R3_filtered <- CalcTraffic( R3_filtered, 300000L, 40L ); R4_filtered$traffic <- 0; R4_filtered <- CalcTraffic( R4_filtered, 300000L, 40L ); ###################################################################### # Model development with data 1 and 2 ###################################################################### # Merge data by direction left <- rbind( L1_filtered, L2_filtered ) right <- rbind( R1_filtered, R2_filtered ) # Split by traffic level - 110 -
left_low <- left[ left$traffic == 1, ] left_hgh <- left[ left$traffic == 2, ] right_low <- right[ right$traffic == 1, ] right_hgh <- right[ right$traffic == 2, ] # Extract time-headway data only in unit of sec. ll_t <- left_low$time_headway_msec / 1000. lh_t <- left_hgh$time_headway_msec / 1000. rl_t <- right_low$time_headway_msec / 1000. rh_t <- right_hgh$time_headway_msec / 1000. length( ll_t ); mean( ll_t ); sd( ll_t ); 3600./mean( ll_t ); length( lh_t ); mean( lh_t ); sd( lh_t ); 3600./mean( ll_t ); length( rl_t ); mean( rl_t ); sd( rl_t ); 3600./mean( ll_t ); length( rh_t ); mean( rh_t ); sd( rh_t ); 3600./mean( ll_t ); ###################################################################### # Begin of Chi-squared Test # aggregation interval size in seconds int_sz <- 0.5 # do test ll05 <- ChisqTest( ll_t, int_sz ); lh05 <- ChisqTest( lh_t, int_sz ); rl05 <- ChisqTest( rl_t, int_sz ); rh05 <- ChisqTest( rh_t, int_sz ); # write outputs write.csv( ll05, "out/left_low_05.csv" ); write.csv( lh05, "out/left_hgh_05.csv" ); write.csv( rl05, "out/right_low_05.csv" ); write.csv( rh05, "out/right_hgh_05.csv" ); # # End of Chi-squared Test # # Begin of drawing graph BiGraph_NE( ll_t, c(0.5*0:60), "Time Headway Distribution\n(Left, Low Traffic)" ) BiGraph_ShNE( ll_t, c(0.5*0:60), "Time Headway Distribution\n(Left, Low Traffic)" ) BiGraph_Norm( ll_t, c(0.5*0:60), - 111 -
"Time Headway Distribution\n(Left, Low Traffic)" ) BiGraph_Pearson( ll_t, c(0.5*0:60), "Time Headway Distribution\n(Left, Low Traffic)" ) BiGraph_NE( lh_t, c(0.5*0:60), "Time Headway Distribution\n(Left, High Traffic)" ) BiGraph_ShNE( lh_t, c(0.5*0:60), "Time Headway Distribution\n(Left, High Traffic)" ) BiGraph_Norm( lh_t, c(0.5*0:60), "Time Headway Distribution\n(Left, High Traffic)" ) BiGraph_Pearson( lh_t, c(0.5*0:60), "Time Headway Distribution\n(Left, High Traffic)" ) BiGraph_NE( rl_t, c(0.5*0:60), "Time Headway Distribution\n(Right, Low Traffic)" ) BiGraph_ShNE( rl_t, c(0.5*0:60), "Time Headway Distribution\n(Right, Low Traffic)" ) BiGraph_Norm( rl_t, c(0.5*0:60), "Time Headway Distribution\n(Right, Low Traffic)" ) BiGraph_Pearson( rl_t, c(0.5*0:60), "Time Headway Distribution\n(Right, Low Traffic)" ) BiGraph_NE( rh_t, c(0.5*0:60), "Time Headway Distribution\n(Right, High Traffic)" ) BiGraph_ShNE( rh_t, c(0.5*0:60), "Time Headway Distribution\n(Right, High Traffic)" ) BiGraph_Norm( rh_t, c(0.5*0:60), "Time Headway Distribution\n(Right, High Traffic)" ) BiGraph_Pearson( rh_t, c(0.5*0:60), "Time Headway Distribution\n(Right, High Traffic)" ) # # End of drawing graph # ###################################################################### # Verification with data 3 and 4 ###################################################################### - 112 -
# Merge data by direction left2 <- rbind( L3_filtered, L4_filtered ) right2 <- rbind( R3_filtered, R4_filtered ) # Split by traffic level left_low2 <- left2[ left2$traffic == 1, ] left_hgh2 <- left2[ left2$traffic == 2, ] right_low2 <- right2[ right2$traffic == 1, ] right_hgh2 <- right2[ right2$traffic == 2, ] # Extraction of time-headway data ll_t2 <- left_low2$time_headway_msec / 1000. lh_t2 <- left_hgh2$time_headway_msec / 1000. rl_t2 <- right_low2$time_headway_msec / 1000. rh_t2 <- right_hgh2$time_headway_msec / 1000. length( ll_t2 ); mean( ll_t2 ); sd( ll_t2 ) length( lh_t2 ); mean( lh_t2 ); sd( lh_t2 ) length( rl_t2 ); mean( rl_t2 ); sd( rl_t2 ) length( rh_t2 ); mean( rh_t2 ); sd( rh_t2 ) # Begin of Chi-squared Test # aggregation interval size in seconds int_sz <- 0.5 # do test ll052 <- ChisqTest( ll_t2, int_sz ); lh052 <- ChisqTest( lh_t2, int_sz ); rl052 <- ChisqTest( rl_t2, int_sz ); rh052 <- ChisqTest( rh_t2, int_sz ); # write outputs write.csv( ll052, "out/veri_left_low_05.csv" ); write.csv( lh052, "out/veri_left_hgh_05.csv" ); write.csv( rl052, "out/veri_right_low_05.csv" ); write.csv( rh052, "out/veri_right_hgh_05.csv" ); # # End of Chi-squared Test # # Begin of drawing graph BiGraph_NE( ll_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Left, Low Traffic)" - 113 -
) BiGraph_ShNE( ll_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Left, Low Traffic)" ) BiGraph_Norm( ll_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Left, Low Traffic)" ) BiGraph_Pearson( ll_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Left, Low Traffic)" ) BiGraph_NE( lh_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Left, High Traffic)" ) BiGraph_ShNE( lh_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Left, High Traffic)" ) BiGraph_Norm( lh_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Left, High Traffic)" ) BiGraph_Pearson( lh_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Left, High Traffic)" ) BiGraph_NE( rl_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Right, Low Traffic)" ) BiGraph_ShNE( rl_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Right, Low Traffic)" ) BiGraph_Norm( rl_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Right, Low Traffic)" ) BiGraph_Pearson( rl_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Right, Low Traffic)" ) BiGraph_NE( rh_t2, c(0.5*0:60), - 114 -
"Time Headway Distribution (Verification)\n(Right, High Traffic)" ) BiGraph_ShNE( rh_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Right, High Traffic)" ) BiGraph_Norm( rh_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Right, High Traffic)" ) BiGraph_Pearson( rh_t2, c(0.5*0:60), "Time Headway Distribution (Verification)\n(Right, High Traffic)" ) # End of drawing graph 2. Util.r # Begin of file # File name: FnBicycle.R # * Function name: CaclTraffic # * Description: # # [in] df : data frame # [in] interval : time interval for collecting traffic volume # [in] cut_pt : divinding point of traffic volume for low and high # # ******************************************************************* CalcTraffic <- function ( df, interval, cut_pt ) { sum <- 0L i <- 1L cnt <- vector( mode = "integer", length = 10L ) while ( sum < nrow( df ) ) { cond <- df$follower_time_msec > (i-1l)*interval+0.0001 & df$follower_time_msec < i*interval cnt[i] <- nrow( df[ cond, ] ); if ( cnt[i] < cut_pt ) df[ cond, ]$traffic <- 1 else df[ cond, ]$traffic <- 2-115 -
sum <- sum + cnt[i]; } i <- i+1; } return( df ); # ******************************************************************* # # * Function name: CaclTrafficNSpeed # * Description: # # [in] df : data frame # [in] moving_sz : moving size in rolling average # [in] summation_sz : summation interval size # # ******************************************************************* CalcTrafficNSpeed <- function ( df, moving_sz, summation_sz ) { MV_SZ <- moving_sz # moving size (e.g. 30s, 1min,... ) SUM_SZ <- summation_sz # summation size (e.g. 30s, 1min,... ) MX_TM <- max( df$follower_time_msec ) tm <- 0L out <- data.frame( vol = double(), spd = double() ); while( tm < MX_TM ) { tmp <- df[ df$follower_time_msec >= tm & df$follower_time_msec < tm+sum_sz, ] out <- rbind( out, data.frame( vol = length( tmp$follower_time_msec ), spd = mean(tmp$speed))) tm <- tm + MV_SZ } tmp; out; tm; out <- out[ out$vol > 0, ] return( out ) } - 116 -
# ******************************************************************* # # * Function name: ChisqTest # * Description: # # [in] ll_t : time headway data # [in] int_sz : aggregation interval size (e.g. 0.5 sec) # # ******************************************************************* ChisqTest <- function( ll_t, int_sz ) { interval <- c(int_sz*0:(30/int_sz)) int_min = c( int_sz*0:((30/int_sz)-1)) int_max = c( int_sz*1:(30/int_sz)) lambda <- 1./mean( ll_t ) th_mean <- mean( ll_t ) th_sd <- sd( ll_t ) th_sd_may <- SdMay( ll_t ) # class( ll ); class( ll_f ); ll_df <- as.data.frame( table( cut( ll_t, breaks = (interval-0.0001) ) ) ) ll_df <- transform(ll_df, cumfreq = cumsum(freq), relative = prop.table(freq)) llow <- data.frame( min = int_min, max = int_max ) llow <- transform( llow, obs_freq = ll_df$freq, obs_prob = prop.table( ll_df$freq ) ) # Negative exponential distribution llow$exp_prob <- pexp( llow$max, rate = lambda ) - pexp( llow$min, rate = lambda ) llow$exp_freq <- round( llow$exp_prob * sum( llow$obs_freq ), digits = 0 ) # # Shifted negative exponential distribution llow$s.exp_prob <- pexp( llow$max-0.5, rate = lambda ) - pexp( llow$min-0.5, rate = lambda ) llow$s.exp_freq <- round( llow$s.exp_prob*sum( llow$obs_freq ), digits = 0 ) # Normal distribution - 117 -
llow$norm_prob <- pnorm( llow$max, th_mean, th_sd ) - pnorm( llow$min, th_mean, th_sd ) llow$norm_freq <- round( llow$norm_prob * sum( llow$obs_freq ), digits = 0 ) # Pearson type III distribution piiipars <- list( shape=th_mean/th_sd_may, location=0, scale=th_sd_may ) llow$pearson_prob <- ppearsoniii( llow$max, params = piiipars ) - ppearsoniii( llow$min, params = piiipars ) llow$pearson_freq <- round( llow$pearson_prob * sum( llow$obs_freq ), digits = 0) sum( llow$exp_prob ); sum( llow$exp_freq ) sum( llow$s.exp_prob ); sum( llow$s.exp_freq ) sum( llow$norm_prob ); sum( llow$norm_freq ) sum( llow$pearson_prob ); sum( llow$pearson_freq ) # Chi-squared statistics chisq.obs <- CalcChisqStatistics( llow$obs_freq, llow$obs_freq ) chisq.exp <- CalcChisqStatistics( llow$obs_freq, llow$exp_freq ) chisq.s.exp <- CalcChisqStatistics( llow$obs_freq, llow$s.exp_freq ) chisq.norm <- CalcChisqStatistics( llow$obs_freq, llow$norm_freq ) chisq.pearson <- CalcChisqStatistics( llow$obs_freq, llow$pearson_freq ) # Chi-squared value chisq.95 <- qchisq(.95, df=length( llow$obs_prob)-1 ) chisq.97 <- qchisq(.97, df=length( llow$obs_prob)-1 ) chisq.99 <- qchisq(.99, df=length( llow$obs_prob)-1 ) print( sprintf("cnt: Obs(%d) Exp(%d) SExp(%d) Norm(%d) Pearson(%d)", sum(llow$obs_freq), sum(llow$exp_freq), sum(llow$s.exp_freq), sum(llow$norm_freq), sum(llow$pearson_freq) ) ) - 118 -
print( sprintf( "CHISQ-STAT: Exp (%7.4f vs %7.4f (%s) )", chisq.exp, chisq.99, chisq.exp < chisq.99 ) ) print( sprintf( "CHISQ-STAT: S-Exp (%7.4f vs %7.4f (%s) )", chisq.s.exp, chisq.99, chisq.s.exp < chisq.99 ) ) print( sprintf( "CHISQ-STAT: Norm (%7.4f vs %7.4f (%s) )", chisq.norm, chisq.99, chisq.norm < chisq.99 ) ) print( sprintf( "CHISQ-STAT: Pearson (%7.4f vs %7.4f (%s) )", chisq.pearson, chisq.99, chisq.pearson < chisq.99 ) ) } return( llow ) # ******************************************************************* # # * Function name: CalcChisqStatistics # * Description: # # [in] obs : observed data # [in] exp : experiment data # # ******************************************************************* CalcChisqStatistics <- function ( obs, exp ) { cnt <- length( obs ); sum <- 0.; for (i in 1:cnt) { if ( exp[i] < 0.00000000001 ) next; c <- (obs[i]-exp[i])*(obs[i]-exp[i]) / exp[i]; sum <- sum + c; } } return( sum ) SdMay <- function ( vals ) { - 119 -
} return ( (mean(vals) - 0.5) * 0.5 ) # ******************************************************************** # # * Function name: BiGraph_NE # * Description: Negative exponential graph drawing # # [in] ll_t: vector of time headway # [in] interval: e.g. c(0.5*0:60) -> 0, 0.5, 1,..., 29.5, 30 # [in] main_title: the title of the graph # # ******************************************************************** BiGraph_NE <- function ( ll_t, interval, main_title ) { hist( ll_t, density = 50, breaks = interval, prob = TRUE, ylim = c(0, 0.4), col = "darkturquoise", xlab = "time headway (sec) ", main = main_title ) x <- seq( -4, 4, length = 100 ) curve( dexp(x, rate = 1./mean( ll_t ) ), lty = 2, col="firebrick2", lwd=2, add=true, yaxt="n" ) } legend("topright", inset=.05, c("exponential"), col = c("firebrick2"), lty = c( 2 ), horiz=false ) # ******************************************************************** # # * Function name: BiGraph_ShNE # * Description: Shifted negative exponential graph drawing # # [in] ll_t: the vector of time headway # [in] interval: e.g. c(0.5*0:60) -> 0, 0.5, 1,..., 29.5, 30-120 -
# [in] main_title: the title of the graph # # ******************************************************************** BiGraph_ShNE <- function ( ll_t, interval, main_title ) { hist( ll_t, density = 50, breaks = interval, prob = TRUE, ylim = c(0, 0.4), col = "darkturquoise", xlab = "time headway (sec) ", main = main_title ) x <- seq( -4, 4, length = 100 ) curve( dexp(x-0.5, rate = 1./mean( ll_t ) ), lty = 2, col = "firebrick2", lwd = 2, add = TRUE, yaxt= "n" ) } legend("topright", inset=.05, "Shifted-Exponential", col = "firebrick2", lty = 2, horiz=false ) # ******************************************************************** # # * Function name: BiGraph_Norm # * Description: Normal distribution graph drawing # # [in] ll_t: the vector of time headway # [in] interval: e.g. c(0.5*0:60) -> 0, 0.5, 1,..., 29.5, 30 # [in] main_title: the title of the graph # # ******************************************************************** BiGraph_Norm <- function ( ll_t, interval, main_title ) { hist( ll_t, density = 50, breaks = interval, - 121 -
prob = TRUE, ylim = c(0, 0.4), col = "darkturquoise", xlab = "time headway (sec) ", main = main_title ) x <- seq( -4, 4, length = 100 ) curve( dnorm(x, mean=mean( ll_t ), sd= sd( ll_t ) ), lty = 2, col="firebrick2", lwd=2, add=true, yaxt="n" ) } legend("topright", inset=.05, "Normal", col = "firebrick2", lty = 2, horiz=false ) # ******************************************************************** # # * Function name: BiGraph_Pearson # * Description: Pearson type III graph drawing # # [in] ll_t: the vector of time headway # [in] interval: e.g. c(0.5*0:60) -> 0, 0.5, 1,..., 29.5, 30 # [in] main_title: the title of the graph # # ******************************************************************** BiGraph_Pearson <- function ( ll_t, interval, main_title ) { hist( ll_t, density = 50, breaks = interval, prob = TRUE, ylim = c(0, 0.4), col = "darkturquoise", xlab = "time headway (sec) ", main = main_title ) - 122 -
} x <- seq( -4, 4, length = 100 ) piiipars <- list( shape=mean(ll_t)/sdmay(ll_t), location=0, scale=sdmay( ll_t ) ) curve( dpearsoniii(x, params=piiipars), lty = 2, col="firebrick2", lwd=2, add=true, yaxt="n" ) legend("topright", inset=.05, "Normal", col = "firebrick2", lty = 2, horiz=false ) - 123 -
- 124 -
- 125 -
- 126 -
- 127 -
- 128 -
- 129 -
- 130 -
- 131 -
- 132 -
- 133 -
- 134 -
- 135 -
- 136 -
- 137 -
- 138 -
- 139 -
- 140 -
- 141 -
- 142 -
- 143 -
- 144 -
- 145 -
- 146 -
- 147 -
- 148 -
- 149 -
- 150 -
- 151 -
- 152 -
- 153 -
- 154 -
- 155 -
- 156 -
- 157 -
- 158 -
- 159 -