lunes, 21 de mayo de 2012

OCTAVE

% Parameter M adjacency matrix where M_i,j represents the link from 'j' to 'i', such that for all 'j' sum(i, M_i,j) = 1
% Parameter d damping factor
% Parameter v_quadratic_error quadratic error for v
% Return v, a vector of ranks such that v_i is the i-th rank from [0, 1]
 
function [v] = rank(M, d, v_quadratic_error)

N = size(M, 2);  % N is equal to half the size of M
v = rand(N, 1);
v = v ./ norm(v, 2);
last_v = ones(N, 1) * inf;
M_hat = (d .* M) + (((1 - d) / N) .* ones(N, N));

    while(norm(v - last_v, 2) > v_quadratic_error)
        last_v = v;
        v = M_hat * v;
        v = v ./ norm(v, 2);
    end

endfunction



function [M]=GenerarM(size)
M=sparse(size,size);

for i=1:size
    for j=1:size
        if (i!=j)
            if (rand(1)>=0.75)
                M(i,j)=1;
            endif
        endif
    endfor
endfor 

MuestraM=full(M)

for j=1:size
    suma=0;
    for i=1:size
        suma=suma+M(i,j);        
    endfor
    for i=1:size
        M(i,j)=M(i,j)/suma;        
    endfor
endfor 



M=full(M);



endfunction


v=rank(GenerarM(15), 0.80, 0.001)

bar(v,'facecolor',"green")
title('Page Rank de las Paginas','Fontsize',48);
ylim([0,1])
xlim([0,16])  
xlabel('NUMERO DE PAGINA','Fontsize',32)
ylabel('PAGE RANK','Fontsize',32)


print -djpg "grafica.jpg"


lunes, 7 de mayo de 2012

R - Tarea


R is an open source programming language and software environment for statistical computing and graphics. The R language is widely used among statisticians for developing statistical software and data analysis.
 Herramientas de cómputo - R
Archivo datos.dat
   Observation Gender Dosage Alertness
1            1      m      a         8
2            2      m      a        12
3            3      m      a        13
4            4      m      a        12
5            5      m      b         6
6            6      m      b         7
7            7      m      b        23
8            8      m      b        14
9            9      f      a        15
10          10      f      a        12
11          11      f      a        22
12          12      f      a        14
13          13      f      b        15
14          14      f      b        12
15          15      f      b        18
16          16      f      b        22
> file=datos.dat
> data.example=read.table(file,header=T)   
> data.example                             
> aov.ex2 = aov(Alertness~Gender*Dosage,data=data.example)
> summary(aov.ex2)                                
> print(model.tables(aov.ex2,"means"),digits=3)