[julia-users] Re: Question on tuple size

2015-01-31 Thread jspark

Dear Kirill Ignatiev;

Crystal clear and thanks for your kind explanation...

Jase


On Saturday, January 31, 2015 at 5:09:47 PM UTC+11, Jung Soo Park wrote:
>
> Hi,
>
> I am generating two functions and the outcome of the first function will 
> be use as input values of the second function.
>
> Like Matlab's case of [x,y,z] =test_function(input), I used Julia's tuple 
> function to generate [x,y,z] and it worked well.
>   
>function test_function(input)
>  x=rand(20,5);
>  y=rand(30,50);
>  z=rand(5,100);
>  ALL=tuple(x,y,z);
>  return ALL
>end
>
>I sliced the output of ALL with [[ ]] and save as xx,yy,zz.
>   
>  ALL= test_function(best)
>  xx=ALL[[1]];
>  yy=ALL[[2]];
>  zz=ALL[[3]];
>
>But I found the size of original output (say x) and sliced (say xx) are 
> not identical so I can not transfer the values into the second function.   
>size(x)
>(20,5)
>
> size(xx)
> `size` has no method matching size(::(Array{Float64,2},))
>
>   while loading In[1], in expression starting on line 12
>
>
> Q) How can I convert the size of xx into size of x so that I can run 
> my second function like following?
>
> function test_2(x,y,z)
> smile!!
> end
> 
>
>   Thank you for your time.
>  
>   Jase
>


[julia-users] Strange Type Errors

2015-01-14 Thread jspark


Hi,

I am trying to port following simple Matlab code into Julia to get 
*mu*

M=500

m_plus=M*0.2;

m_0=M*0.1;

m_minus=M*0.7; 


mu_plus=0.15+0.5*(1:m_plus)/m_plus;

mu_minus=-3*(1:m_minus)/m_minus;

mu_0=zeros(1,m_0);


*mu*=[mu_plus mu_0  mu_minus]


However, with Julia, this is never a simple task because of the too sensitive 
type specification.


I have no problem upto line 6 but I had error on line 7 or zeros().   


`Array{T,N}` has no method matching Array{T,N}(::Type{Float64}, ::Int64, 
::Float64)
while loading In[121], in expression starting on line 1 in zeros at array.jl:170


It worked when I changed 50.0 into 50 in zeros() and I made change in code to 
convert float into integer with convert()and ::  


convert(Int32,m_0);

m_0= m_0::Int32

but not works


The second error was concatenation. 


mu_plus=0.15+0.5*(1:m_plus)/m_plus;

mu_minus=-3*(1:m_minus)/m_minus;

mu_0=zeros(1,50);

mu=[mu_plus mu_0  mu_minus]


number of rows must match while loading In[133], in expression starting on line 
4

in hcat at abstractarray.jl:571


This may be the reason of different date type as well.


The type of mu_plus and mu_minus are FloatRange{Float64} (constructor with 1 
method), 

while that of mu_0 is Array{Float64,2}


Could you let be know the basics that I still need to practice? 


Many thanks.







[julia-users] DomainError

2015-01-03 Thread jspark

Hi,

I am running one page of script but I get following DomainError;

ERROR : DomainError in sin at math.jl:122 in ^at math.jl:255 

Is it my side's error or Julia's

Thanks.




[julia-users] ARIMA function not working

2015-01-01 Thread jspark
Hi,

Now I become a two weeks old for Julia and still struggling with Julia.

I am porting *AR1 function* below from a *cran R* but for some reason it 
gives me an error (SingularException(3)) when I convert *solve() to get 
Alpha* into *inv()*. However, it works with R and Matlab.

y=float(r,1])  # r is data vector from the attached DJ.csv file

T = length(y)-1;

Y = y[2:T]';

Y1= y[1:(T-1)]';

Alpha= inv(Y1'.*Y).*(Y1').*Y;


*ERROR : SingularException(3)*

As an alternative, I am trying to get AR1 coefficient from *arima() *of the 
*TimeModels*  package but it's not working either.

using TimeModels

zz=rand(500,1);   #500*1 Array(Float64,2)
arima(zz,1,0,0); 

*ERROR : 'arima' has no method matching arima (::Array{Float64,2), ::Int64, 
::Int64, ::Int64)*

Can someone tell me what is the behind story of the error?

Many thanks and Happy New Year to all!!
  

AR1 <-function(x){T <- length(x) -1Y <- x[2:T]Y_ <- x[1:(T-1)] ALPHA <- 
solve(t(Y_) %*% Y_ ) %*% t(Y_) %*% YRE <- Y - Y_ %*% ALPHASIGMAS <- sum(RE^2) 
/ (T-1)STDA <- sqrt( SIGMAS * solve(t(Y_) %*% Y_ ))return(list(ALPHA=ALPHA,
STDA=STDA))} Source : ttps://github.com/cran/vrtest/blob/master/R/AR1.R

-0.009123476
0.012309363
0.001955513
-0.001955513
0.002443794
-0.001710029
-0.003674223
0.015825041
0.001207001
0.008169195
0.011420538
0.012927669
-0.001402197
0.011394147
-0.01092653
-0.00609615
-0.002354604
-0.009474254
-0.002621233
0.00736958
-0.000236883
-0.007848774
0.004288784
0.011817675
-0.004238292
-0.008530857
-0.002144134
-0.015139061
-0.001696353
0.004597709
-0.007512455
-0.013222524
0
-0.007422102
-0.013751936
0.000503398
0.013993232
0
0.000496155
-0.000992556
0.00763
0.002460631
0.001718846
-0.013585487
0.026504619
0.010120568
-0.000479616
0.004547094
0.00595169
-0.018929522
0.002657327
-0.00338328
0.014181226
-0.006705006
0.004076255
0.003582949
0.002619361
0.005691265
-0.004978083
-0.003571007
-0.010308134
0.00240674
-0.011605546
0.003156492
0.003388193
-0.012887716
-0.006383523
-0.000492732
-0.01264741
-0.013821052
-0.009917437
0.018483879
-0.009832425
0.00757197
0.001005278
0.002007529
-0.003767429
-0.004286982
0.004035314
0.015980365
-0.003971214
0.001987578
-0.008474627
0.011943411
-0.016710702
-0.008841791
-0.008664682
-0.014956442
0.005182701
0.005670118
-0.008776515
-0.002076305
0.001298196
0.017490158
-0.005112486
-0.000256312
-0.001282545
-0.005920985
0.001290156
0.017889565








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Re: [julia-users] Fail for installation of the cholpfact () in factorization package

2014-12-28 Thread jspark
It works and thanks for your kind help

On Sunday, December 28, 2014 8:48:55 PM UTC+11, Andreas Noack wrote:
>
> The content of factorization.jl is already part of the base julia, but we 
> haven't had the cholpfact method for a while. Instead you can use a keyword 
> to get the pivoted cholesky. E.g.
>
> cholfact(A, pivot = true, tol = 1e-8)
>
> Where tol is the tolerance for the rank determination.
>
> 2014-12-28 10:07 GMT+01:00 jspark >:
>
>> For some reason I failed to install factorization package to use 
>> cholpfact function. I tried
>>
>> Pkg.add("factorization")
>>
>> Pkg.clone("
>> https://github.com/JuliaLang/julia/blob/master/base/linalg/factorization.jl
>> ")
>>
>> Pkg.clone("
>> https://github.com/JuliaLang/julia/blob/master/base/linalg/factorization.jl
>> ")
>>
>> But I got
>>
>> *ERROR: chmod: no such file or directory (ENOENT)*
>>
>> Thank you everyone.
>>
>>
>

[julia-users] Fail for installation of the cholpfact () in factorization package

2014-12-28 Thread jspark
For some reason I failed to install factorization package to use cholpfact 
function. I tried

Pkg.add("factorization")

Pkg.clone("https://github.com/JuliaLang/julia/blob/master/base/linalg/factorization.jl";)

Pkg.clone("https://github.com/JuliaLang/julia/blob/master/base/linalg/factorization.jl";)

But I got

*ERROR: chmod: no such file or directory (ENOENT)*

Thank you everyone.



[julia-users] Porting a Matlab function, mvtrnd, multivariate t distribution number generation

2014-12-26 Thread jspark
Hi,

I am porting a matlab random number generation from multivariate T 
distribution and attached, I am converting the mvtrnd.m function of Matlab.

This is mixed version of Julia and original Matlab scripts and nonetheless 
of my series of the modifications, it still making a error to me.

Last error message is "* in apply, expected Function, got Int 64 in mvtrnd3 
at C:\\~mvtrnd3.jl:32 "*

Thank you.

 


mvtrnd3.jl
Description: Binary data


[julia-users] convert Matlab code into Julia

2014-12-23 Thread jspark

Hi,

I am a *two days *old beginner for *Julia* and it seemed I can translate 
*Matlab* code into Julia in a second (?) but the reality is always 
different...
The goal for original *Matlab* code was to select eight time series data 
files (matlab format) in a folder(directory) and run the data analysis with 
"for loop" one by one. 
Now it looks like *Juila* code but it is not yet working because 1) it 
still use *Matlab *functions like dir() and 2) it need to run data files in 
*.mat* format.   
I have error from dirData = (line 5) and could you help me out from there?

#set file path

loadPath="E:\USA\Data\Data111" ;

#select only Matlab files

cd(loadPath)

dirData = dir("*.mat"); ## Selected mat files
fileNames = {dirData.name}; ## named the list of the files as fileNames

#run loop 

for s=1:8 
  
FN=fileNames(s) # select one file 
DATA=load(char(FN))

"run additional codes"

end;