,基於開源軟體的資料分析

來源:互聯網
上載者:User

在linux字元系統中安裝以下軟體

1. 安裝python +numpy+scipy+matplotlib(enthought成功)

2.安裝 R(成功)

3. 安裝gnuplot(安裝成功)

4. 安裝GSL

1.的安裝檔案

epd_free-7.3-2-rh5-x86_64.sh

安裝成功的測試指令碼

 

#-*-coding:gbk-*-
#########################################################################
#   Copyright (C) 2013 All rights reserved.
#
#   檔案名稱:a.py
#   創 建 者:劉禹 finallyly

#   建立日期:2013年01月27日
#   描    述:
#
#   備    註:
#
#########################################################################
#!/usr/bin/python
# please add your code here!
import matplotlib
matplotlib.use('Agg') # Must be before importing matplotlib.pyplot or pylab!
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
x=np.linspace(0,10,100);
plt.plot(x,np.sin(x));
fig.hold();
x=np.linspace(0,10,100);
plt.plot(x,0.5*np.cos(2*x));
plt.title("A matplotlib plot");
plt.text(1,-0.8,"cos func");
plt.ylim(-1.1,1.1);
fig.savefig('temp.png')

運行: liuyu: ~/MyTars/epd_free-7.3-2-rh5-x86_64/bin/Workbench$ ../python2.7 a.py

2.的安裝參加http://blog.sina.com.cn/s/blog_61f013b80100yhef.html,我安裝的版本是 R-2.15.2

2安裝成功運行

 

3. 安裝的版本是gsl-1.9,安裝的位置是liuyu: ~/GSL4. 安裝完上述四個開源庫後我的.bashrc內容如下 

export PATH=$PATH:/home/liuyu/MyTars/epd_free-7.3-2-rh5-x86_64/bin                
export PATH=$PATH:/home/liuyu/MyTars/R-2.15.2/bin                                 
export R_HOME=/home/liuyu/MyTars/R-2.15.2/bin/R
export R_LIBS=/search/liuyu/MyTars/R-2.15.2/library
export LD_LIBRARY_PATH=${R_HOME}/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}  
export LD_LIBRARY_PATH=/home/liuyu/GSL/lib:${LD_LIBRARY_PATH} 

5. 源碼安裝軟體的方式

tar -xzvf source.tar.gz

cd source

./configure --prefix=dir//指定安裝目錄

make

make install

卸載 make uninstall

6.程式調用GSL庫(使用automake做編譯)

Makefile.am的內容

 include $(top_srcdir)/common.mk
 
 bin_PROGRAMS=
 lib_LIBRARIES=
  ib_LTLIBRARIES=
  
  bin_PROGRAMS+=test
  INCLUDES=-I /search/liuyu/GSL/include
  test_SOURCES=test.cpp                                                                                         
 test_LDADD=  /home/liuyu/GSL/lib/libgsl.so /home/liuyu/GSL/li
    b/libgslcblas.so 
 test_LDFLAGS=-static-libtool-libs

test.cpp的源碼

===============================================================*   Copyright (C) 2013 All rights reserved.*   *   檔案名稱:a.cpp*   創 建 者:劉禹 finallyly *   建立日期:2013年01月27日*   描    述:*   備    注: *   更新日誌:*================================================================*/ // please add your code here!#include<stdio.h>#include "gsl/gsl_vector.h"#include "gsl/gsl_matrix.h"#include "gsl/gsl_blas.h"#include "gsl/gsl_linalg.h"int main(){    double r;    gsl_vector *a,*b,*s,*t;    gsl_matrix *m,*v;    a=gsl_vector_alloc(2);    b=gsl_vector_alloc(2);    gsl_vector_set(a,0,1.0);    gsl_vector_set(a,1,2.0);    gsl_vector_set(b,0,3.0);    gsl_vector_set(b,1,6.0);    gsl_vector_add(a,b);    gsl_vector_fprintf(stdout,a,"%f");    gsl_blas_ddot(a,b,&r);    fprintf(stdout,"%f\n",r);    s=gsl_vector_alloc(2);    t=gsl_vector_alloc(2);    m=gsl_matrix_alloc(2,2);    v=gsl_matrix_alloc(2,2);    gsl_matrix_set(m,0,0,1.0);    gsl_matrix_set(m,0,1,2.0);    gsl_matrix_set(m,1,0,0.0);    gsl_matrix_set(m,1,1,3.0);    gsl_linalg_SV_decomp(m,v,s,t);    gsl_vector_fprintf(stdout,s,"%f");    gsl_vector_free(a);    gsl_vector_free(b);    gsl_vector_free(s);    gsl_vector_free(t);    gsl_matrix_free(m);    gsl_matrix_free(v);    return 0;}

 運行結果:

 

 gnuplot安裝1. 下載wxGTK-2.8.12-i486-1alien.tgz,解壓後將libwx_gtk2u_richtext-2.8.so.0.8.0拷貝至/usr/local/lib(之所以放在這裡是因為/etc/ld.so.conf中指定了這個目錄為動態連結程式庫的功能目錄)2. 然後 進入源碼,以root身份安裝我的gnuplot源碼為gnuplot-4.6.rc1.tar.gz3. 之後配置bashrc中的path export PATH=$PATH:gnuplot的安裝目錄4.調用 檔案名稱plot.gp中有以下內容1 plot sin(x)                                                                                                                 
  2 set grid
  3 set xlabel "X"
  4 set ylabel "Y"
  5 set terminal png
  6 set output "plot.png"
  7 replotgnuplot plog.gp會在當前路徑下產生plot.png 

f=scan(file="f3.txt");
quantile(f,0.01);
#png(file="myplot2.png", bg="transparent");
#boxplot(f);
fivenum(f);
summary(f);

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.