99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
首頁精彩閱讀數(shù)據(jù)分析之_散點(diǎn)圖?_數(shù)據(jù)分析師
數(shù)據(jù)分析之_散點(diǎn)圖?_數(shù)據(jù)分析師
2014-11-26
收藏

數(shù)據(jù)分析之_散點(diǎn)圖_數(shù)據(jù)分析師


一:什么是散點(diǎn)圖 - What is a scatter plot

任何數(shù)據(jù)分析的第一步是圖形化曲線顯示數(shù)據(jù),根據(jù)相互關(guān)系,圖形曲線被稱為散點(diǎn)圖。散點(diǎn)圖可以表示兩個(gè)變量之間真實(shí)的關(guān)系強(qiáng)度,關(guān)系的趨勢,是否存在Outliers

 

二:散點(diǎn)圖的目的是什么

ü         觀察變量之間的關(guān)系,發(fā)現(xiàn)統(tǒng)計(jì)數(shù)據(jù)中是否存在問題,或者特殊值和感興趣的數(shù)據(jù)

ü         數(shù)據(jù)是如何被離散化的

ü         通過眼睛觀察是否存在Outliers

 

三:示例說明

一個(gè)人的肺活量和屏住呼吸時(shí)間的研究,一個(gè)人能屏住呼吸多久,一個(gè)研究者選擇一組人作為研究對(duì)象,測量每個(gè)人的肺活量作為第一個(gè)變量,屏住呼吸時(shí)間作為第二個(gè)變量,研究者將使用散點(diǎn)圖來描述數(shù)據(jù),假設(shè)肺活量作為水平軸,屏住呼吸時(shí)間做為垂直軸。

 

四:代碼實(shí)現(xiàn)

基于Java開源的數(shù)據(jù)圖形顯示組件-JFreeChart已經(jīng)實(shí)現(xiàn)了離散圖,只要我們提供數(shù)據(jù)即可

基于上面描述的演示如下:

 

 

 plot

  

 

五:相關(guān)性系數(shù) correlation coefficient – R/r

r calculation

 

Relationship Between X and Y Axis

r = + 1.0

Strong - Positive

As X goes up, Y always also goes up

r = + 0.5

Weak - Positive

As X goes up, Y tends to usually also go up

r = 0

- No Correlation -

X and Y are not correlated

r = - 0.5

Weak - Negative

As X goes up, Y tends to usually go down

r = - 1.0

Strong - Negative

As X goes up, Y always goes down

 

本例中的r值為0.9814324978439516,顯然肺活量跟屏住呼吸時(shí)間長短有很強(qiáng)的正相關(guān)性。

以下為源代碼:

 package com.dataanalysis.plots;  import java.awt.Color;  import javax.swing.JPanel;  import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.xy.DefaultXYDataset; import org.jfree.data.xy.XYDataset; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities;  // - http://en.wikipedia.org/wiki/Scatter_plot  public class ScatterPlotDemo extends ApplicationFrame {      /** *   */ private static final long serialVersionUID = 1L; private static double[][] data; /**      * A demonstration application showing a scatter plot.      *      * @param title  the frame title.      */     public ScatterPlotDemo(String title) {         super(title);         JPanel chartPanel = createDemoPanel();         chartPanel.setPreferredSize(new java.awt.Dimension(600, 400));         setContentPane(chartPanel);     }      private static JFreeChart createChart(XYDataset dataset) {         JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot Demo",                 "lung capacity(ml)", "time holding breath(s)", dataset, PlotOrientation.VERTICAL, true, false, false);           XYPlot plot = (XYPlot) chart.getPlot();         plot.setNoDataMessage("NO DATA");         plot.setDomainZeroBaselineVisible(true);         plot.setRangeZeroBaselineVisible(true);                  XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();         renderer.setSeriesOutlinePaint(0, Color.black);         renderer.setUseOutlinePaint(true);                  // x axis         NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();         domainAxis.setAutoRange(true);                  // Y axis         NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();         rangeAxis.setAutoRange(true);                  XYTextAnnotation textAnnotation =           new XYTextAnnotation("R = " + calculateCoefficient(data),           370, 25); // r value         textAnnotation.setPaint(Color.BLUE);         textAnnotation.setToolTipText("Correlation Coefficient");          plot.addAnnotation(textAnnotation);                  return chart;     }          /**      * Creates a panel for the demo (used by SuperDemo.java).      *       * @return A panel.      */     public static JPanel createDemoPanel() {         JFreeChart chart = createChart(createXYDataset());         ChartPanel chartPanel = new ChartPanel(chart);         chartPanel.setPopupMenu(null);         chartPanel.setDomainZoomable(true);         chartPanel.setRangeZoomable(true);         return chartPanel;     }          public static XYDataset createXYDataset() {     DefaultXYDataset xyDataset = new DefaultXYDataset();     data = new double[2][12];         // x axis data - lung capacity(ml)     data[0] = new double[]{400,397,360,402,413,427,389,388,405,422,411,433};         // y axis data - time holding breath(s)     data[1] = new double[]{21.7,20.7,17.7,21.9,23.7,25.7,20.4,20.1,22.9,24.8,22.5,25.9};         xyDataset.addSeries("Research Data", data);     System.out.println("Correlation Coefficient = " + calculateCoefficient(data));     return xyDataset;     }          public static double calculateCoefficient(double[][] data) {     DescriptiveStatistics xDataSet = new DescriptiveStatistics(); for(int i=0; i<data[0].length; i="" xdataset="" descriptivestatistics="" ydataset="new" descriptivestatistics="" for="" i="0;" i="" i="" ydataset="" double="" n="yDataSet.getValues().length;" double="" xysum="0.0d;" double="" xpowsum="0.0d;" double="" ypowsum="0.0d;" for="" i="0;" i="" i="" xysum="" xdataset="" ydataset="" xpowsum="" math="" ypowsum="" double="" s1="xySum" -="" ydataset="" double="" xs="xPowSum" -="" double="" ys="yPowSum" -="" double="" s2="Math.sqrt(xS" ys="" return="" s2="" starting="" point="" for="" the="" demonstration="" application="" args="" ignored="" public="" static="" void="" main="" args="" scatterplotdemo="" demo="new" scatterplotdemo="" plot="" demo="" demo="" refineryutilities="" demo=""> </data[0].length;>

數(shù)據(jù)分析咨詢請(qǐng)掃描二維碼

若不方便掃碼,搜微信號(hào):CDAshujufenxi

數(shù)據(jù)分析師資訊
更多

OK
客服在線
立即咨詢
客服在線
立即咨詢
') } function initGt() { var handler = function (captchaObj) { captchaObj.appendTo('#captcha'); captchaObj.onReady(function () { $("#wait").hide(); }).onSuccess(function(){ $('.getcheckcode').removeClass('dis'); $('.getcheckcode').trigger('click'); }); window.captchaObj = captchaObj; }; $('#captcha').show(); $.ajax({ url: "/login/gtstart?t=" + (new Date()).getTime(), // 加隨機(jī)數(shù)防止緩存 type: "get", dataType: "json", success: function (data) { $('#text').hide(); $('#wait').show(); // 調(diào)用 initGeetest 進(jìn)行初始化 // 參數(shù)1:配置參數(shù) // 參數(shù)2:回調(diào),回調(diào)的第一個(gè)參數(shù)驗(yàn)證碼對(duì)象,之后可以使用它調(diào)用相應(yīng)的接口 initGeetest({ // 以下 4 個(gè)配置參數(shù)為必須,不能缺少 gt: data.gt, challenge: data.challenge, offline: !data.success, // 表示用戶后臺(tái)檢測極驗(yàn)服務(wù)器是否宕機(jī) new_captcha: data.new_captcha, // 用于宕機(jī)時(shí)表示是新驗(yàn)證碼的宕機(jī) product: "float", // 產(chǎn)品形式,包括:float,popup width: "280px", https: true // 更多配置參數(shù)說明請(qǐng)參見:http://docs.geetest.com/install/client/web-front/ }, handler); } }); } function codeCutdown() { if(_wait == 0){ //倒計(jì)時(shí)完成 $(".getcheckcode").removeClass('dis').html("重新獲取"); }else{ $(".getcheckcode").addClass('dis').html("重新獲取("+_wait+"s)"); _wait--; setTimeout(function () { codeCutdown(); },1000); } } function inputValidate(ele,telInput) { var oInput = ele; var inputVal = oInput.val(); var oType = ele.attr('data-type'); var oEtag = $('#etag').val(); var oErr = oInput.closest('.form_box').next('.err_txt'); var empTxt = '請(qǐng)輸入'+oInput.attr('placeholder')+'!'; var errTxt = '請(qǐng)輸入正確的'+oInput.attr('placeholder')+'!'; var pattern; if(inputVal==""){ if(!telInput){ errFun(oErr,empTxt); } return false; }else { switch (oType){ case 'login_mobile': pattern = /^1[3456789]\d{9}$/; if(inputVal.length==11) { $.ajax({ url: '/login/checkmobile', type: "post", dataType: "json", data: { mobile: inputVal, etag: oEtag, page_ur: window.location.href, page_referer: document.referrer }, success: function (data) { } }); } break; case 'login_yzm': pattern = /^\d{6}$/; break; } if(oType=='login_mobile'){ } if(!!validateFun(pattern,inputVal)){ errFun(oErr,'') if(telInput){ $('.getcheckcode').removeClass('dis'); } }else { if(!telInput) { errFun(oErr, errTxt); }else { $('.getcheckcode').addClass('dis'); } return false; } } return true; } function errFun(obj,msg) { obj.html(msg); if(msg==''){ $('.login_submit').removeClass('dis'); }else { $('.login_submit').addClass('dis'); } } function validateFun(pat,val) { return pat.test(val); }