Created
June 9, 2013 02:12
-
-
Save nad2000/5737340 to your computer and use it in GitHub Desktop.
Distribution of sample counts per gap value between the current sample and the previous one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(RPostgreSQL) | |
drv <- dbDriver("PostgreSQL") | |
con <- dbConnect(drv, dbname="6", user="postgres", host="192.168.132.111") | |
# dbListConnections(drv) | |
# dbGetInfo(drv) | |
# summary(con) | |
rs <- dbSendQuery(con," | |
SELECT | |
delta, delta_cnt , | |
round(100*delta_cnt::numeric/(sum(delta_cnt) OVER ()),2) \"delta %\" | |
FROM ( | |
SELECT delta, count(*) AS delta_cnt FROM ( | |
SELECT | |
flow_id, | |
last_time_sec-lag(last_time_sec) | |
OVER (partition by flow_id order by last_time_sec /* byte_count_1+byte_count_2*/) AS delta | |
FROM long_flow_samples ) AS d | |
WHERE delta IS NOT NULL -- AND delta != 0 | |
GROUP BY delta | |
ORDER BY 1 DESC ) AS stats") | |
gaps <- fetch(rs,n=-1) | |
plot( | |
gaps$delta_cnt ~ gaps$delta, | |
col="red", | |
xlab="Gaps between samples (sec)", | |
ylab="Sample Counts", | |
main="Distribution of sample counts per gap value between the current sample and the previous one") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment