piwik 高级搜索要点
piwik搜索要点在于getLastVisitsDetails函数,如下:
function getLastVisitsDetails( $idSite, $period = false, $date = false, $segment = false, $filter_limit = false, $maxIdVisit = false, $minTimestamp = false )
根据参数的不同可以设置相关的搜索,其中$idSite位站点编号,$period为时期(包括年,月),$date为日期,$segment为一系列筛选条件,$filter_limit为返回的条数。其中最重要的参数为$segment,可以定义一系列条件:
可以定义的参数如下:
| browserName | Browser Example values: FF, IE, CH, SF, OP, etc. |
| browserVersion | Browser version Example values: 1.0, 8.0, etc. |
| continent | Continent Example values: eur, asi, amc, amn, ams, afr, ant, oce |
| country | Country Example values: de, us, fr, in, es, etc. |
| visitLocalHour | Local time Example values: 0, 1, 2, 3, ..., 20, 21, 22, 23 |
| operatingSystem | Operating system Example values: WXP, WI7, MAC, LIN, AND, IPD, etc. |
| provider | Provider Example values: comcast.net, proxad.net, etc. |
| resolution | Resolution Example values: 1280x1024, 800x600, etc. |
| visitServerHour | Server time Example values: 0, 1, 2, 3, ..., 20, 21, 22, 23 |
| visitEcommerceStatus | Visit Ecommerce status at the end of the visit. For example, to select all visits that have made an Ecommerce order, the API request would contain “&segment=visitEcommerceStatus==ordered,visitEcommerceStatus==orderedThenAbandonedCart” Example values: none, ordered, abandonedCart, orderedThenAbandonedCart |
| visitConvertedGoalId | Visit converted a specific Goal Id Example values: 1, 2, 3, etc. |
| visitConverted | Visit converted at least one Goal Example values: 0, 1 |
| visitorId | Visitor ID Example values: 34c31e04394bdc63 - any 16 Hexadecimal chars ID, which can be fetched using the Tracking API function getVisitorId() |
| visitIp | Visitor IP Note: This segment can only be used by an Admin user Example values: 13.54.122.1, etc. |
| visitorType | Visitor type. For example, to select all visitors who have returned to the website, including those who have bought something in their previous visits, the API request would contain “&segment=visitorType==returning,visitorType==returningCustomer” Example values: new, returning, returningCustomer |
| Referrers | |
| referrerKeyword | Keyword Example values: Encoded%20Keyword, keyword |
| referrerName | Referrer Name Example values: twitter.com, www.facebook.com, Bing, Google, Yahoo, CampaignName |
| referrerType | Referrer Type Example values: direct, search, website, campaign |
| referrerUrl | Referrer URL Example values: http%3A%2F%2Fwww.example.org%2Freferer-page.htm |
用线性回归方法计算直线斜率
关于线性回归可以参考百度知道。其中采用最小二乘法可以比较容易的算出过往设备负载增长的斜率,具体公式如下:
下面代码简单枚举历史10个点来计算该设备负载增长率:
$y = array(52.09, 52.4, 53.29, 54.22, 55.15, 55.83, 56.89, 56.98, 57.55, 57.8);
//X坐标值表示顺序天数
$x = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
//计算X和Y均值
$ax = array_sum($x)/count($x);
$ay = array_sum($y)/count($y);
//计算斜率公式中的分母(em)和分子(ez)
$em = 0;
$ez = 0;
for ($i = 0; $i < count($x); $i++) {
//分母求和
$em += (($x[$i] - $ax) * ($y[$i] - $ay));
//分子求和
$ez += pow(($x[$i] - $ax), 2);
}
//斜率0.69
echo $em/$ez;
//第十一个点预测负载值58.34
echo $em/$ez * 10 + $ay - ($em/$ez)*$ax;
很多概念都不甚懂,反正数学是没有学好的,找来公式代一代,嘿嘿,还算可以,对于波动比较大的就比较难以预测,这个近似值还是很有参考意义的。
回归直线:
如果散点图中点的分布从整体看大致在一条直线附近,我们就称这两个变量之间具有线性相关关系,这条直线叫做回归直线。根据不同的标准,可以画出不同的直线来近似表示这种线性相关关系。比如可以连接最左侧点和最右侧点得到一条直线,或者让画出的直线上方的点和下方的点数目相等。当所有数据点都分布在一条直线附近,显然这样的直线还可以画出许多条,而我们希望找出其中的一条,它能最好地反映x与Y的关系,换言之,我们要找出一条直线,使这条直线“最贴近”已知的数据点。记此直线方程为y^=a+bx。这里在y的上方加记号“^”是为了区分Y的实际值y,表示x取值xi(i=1,2,3……,n)时,Y相应的观察值为yi,而直线上对应于xi的纵坐标是yi^=a+bxi(i为x右下角的数值)。y^=a+bx式叫做Y对x的回归直线方程,b叫回归系数。要确定回归直线方程,只要确定a于回归系数b。
各linux版本重启apache命令
Slackware Linux命令:/etc/rc.d/rc.httpd restart
ubuntu、Debian 系统命令:
/etc/init.d/apache2 restart
Fedora 、Redhat、CentOS系统重启Apache命令:
/etc/init.d/httpd restart
或
service httpd restart(CentOS 成功)
