[julia-users] How to interrupt a loop with a keyboard keystroke

2015-11-10 Thread Felipe Jiménez
I have a long loop going. It solves a solitaire board-game by brute force 
search, and depending on the initial configuration it could take seconds or 
years to finish, I never know.

I would like to be able to interrupt the loop at any time and save its 
state (basically the values in an Array the loop operates on). That would 
allow me to resume the loop later from where it left, instead of starting 
all over again.

Of course Ctrl-C is no good because I lose the state of the loop. My idea 
is something like:

   while true
  # do stuff #
  if (keyboard was pressed) && (key was 'p')  # for "pause"
 save Array to hard disk
 return
  end
   end

But I don't know how to check if "keyboard was pressed" and what key it 
was. I cannot use  chomp(readline())  because this waits until the user 
hits Enter, which stops the loop going (unless I leave a spoon pressing the 
Enter key :-). I need something that looks at the keyboard stack to see if 
a key was recently pressed, and if none was pressed, it does nothing and 
lets the loop continue without delay.

I normally work at the REPL.

Any ideas?

Like always, sorry if my Q is too basic, but I did check the documentation 
and the web and could not solve it.
And a big thank you to the Julia developers and community. I am loving it.


[julia-users] Error plotting graph - plot function returns nothing

2015-11-10 Thread 'Antoine Messager' via julia-users
Dear all,

I am currently trying to plot graphs. I installed both GraphViz and Graph 
packages. I then try to follow the example given in the documentation (and 
written below). I first had to deal with the issue listed here #172 
. Thus I changed the 
dot.jl file in order to use the png instead of the x11 format as explained 
here #176 . The error 
disappeared but now when I want to plot a graph the display function 
returns "nothing":

julia> using Graphs   
  
julia> g = simple_graph(3)
Directed Graph (3 vertices, 0 edges)  
  
julia> add_edge!(g, 1, 2) 
edge [1]: 1 -- 2
julia> add_edge!(g, 3, 2) 
edge [2]: 3 -- 2
julia> add_edge!(g, 3, 1) 
edge [3]: 3 -- 1  
  
julia> display(plot(g))   
Nothing   

Thank you for your help,
Antoine






Re: [julia-users] Using Meshes.ji

2015-11-10 Thread Rohit Thankachan
I've made a few changes to the file Steve pointed you to. It can be found 
at https://gist.github.com/rohitvarkey/5be4542faff17014afc7.

If you use Escher to run that file, you can load .obj files by just typing 
in the filename (provided you ran the Escher server from the directory the 
file exists) or the absolute path to the file in the input field. A very 
primitive mesh viewer in Julia I guess. :)

Regards,
Rohit  

On Monday, 9 November 2015 22:15:01 UTC+5:30, Steve Kelly wrote:
>
> The faces can be accessed with faces(load("foo.obj")) or mesh.faces.
>
> Probably the easiest way to display the mesh at this point is with 
> ThreeJS.jl: 
> https://github.com/rohitvarkey/ThreeJS.jl/blob/master/examples/mesh.jl. 
> This approach should work in IJulia and Blink.
>
> GLVisualize has some good demos and a much more responsive backend, but it 
> needs some work to run in OpenGL < 3.3 and the working commits aren't on 
> Metadata yet. Meshes is kind of a weird state right now, and most of the 
> functionality can be had with GeometryTypes, Meshing, and MeshIO. We have 
> been working the past few months to finish the coupling between data 
> structures for geometry and visualization. It would be great to hear your 
> application, and see if we could achieve something in the short term that 
> would work for you. Personally I use Meshlab when I do solid modelling in 
> Julia which slows down my iteration time, and it would be nice to have a 
> mesh viewer in the workflow.
>
> Best,
> Steve
> On Nov 9, 2015 9:55 AM, "Ashley Kleinhans"  > wrote:
>
>> Hi,
>>
>> I am new at this - but have decided that Julia is my language of choice. 
>> So I begin silly question stage: 
>>
>> Could someone talk me through how to access and display an .obj file? 
>>
>> I have gotten so far:
>>
>> using Meshes
>> using PyPlot
>> using FileIO
>> using MeshIO
>>
>> obj = load(filename)
>> vts = obj.vertices 
>>
>>
>> Which gives me: 
>>
>> 502-element Array{FixedSizeArrays.Point{3,Float32},1}:
>>
>>
>>
>> One example point being: 
>>
>> Point(0.00117,-0.02631,0.03907)
>>
>>  
>>   
>>
>>   
>>
>> How do I access the verticies to use them with plot? 
>>
>> -A
>>
>>
>>

[julia-users] Re: DataFrame to JSON

2015-11-10 Thread JobJob
Good stuff. Here's a stab at the inverse:

function json2df(jsonstr)
dictvec = JSON.parse(jsonstr)
DataFrame(Dict(map(k->(k=>[row[k] for row in dictvec]), keys(dictvec[1
]
end




[julia-users] Re: How to interrupt a loop with a keyboard keystroke

2015-11-10 Thread Páll Haraldsson
On Tuesday, November 10, 2015 at 10:07:17 AM UTC, Felipe Jiménez wrote:
 

>while true
>   # do stuff #
>   if (keyboard was pressed) && (key was 'p')  # for "pause"
>
>  

> Any ideas?
>

Hopefully I'm not complicating, something like this seems not be enough (as 
you could be piping into stdin and something like this would not work):
http://www.cplusplus.com/reference/cstdio/getchar/

You want something like "kbhit()" it seems:

http://www.cprogramming.com/fod/kbhit.html
"Header File: conio.h
Explanation: This function is not defined as part of the ANSI C/C++ 
standard. It is generally used by Borland's family of compilers."

https://support.microsoft.com/en-us/kb/43993

http://cboard.cprogramming.com/c-programming/63166-kbhit-linux.html



I believe this is OS dependent (and last time I did something similar 
keyboard related, it was on non-Julia supported OS, RISC OS..).

readline is good, would be great if Julia Base would abstract away the 
differences between the lower-level keyboard access the OSes use.. but 
since you didn't find anything I guess you can rule out that it has been 
done already.. There might be one exception. Ctrl-C works I think in all 
OSes(?) but should kill your program, maybe you can trap that, but probably 
easier to concentrate on non-Ctrl-C working for you.


The only game library I know available to Julia is kind of an overkill..:

https://github.com/zyedidia/SFML.jl

But this is something (a wrapper for a C++ game library) they have to deal 
with (and much more..) and you could even let a joystick [button] exit your 
loop..


Python for sure must have some way (or at least a [wrapper] library). They 
have SDL game library wrapped with PyGame, and I tried to google something 
else:

http://stackoverflow.com/questions/676713/is-there-a-cross-platform-python-low-level-api-to-capture-or-generate-keyboard-e


With PyCall.jl you could get at anything Python has access too. I hope its 
not too slow, you could check e.g. every tenth iteration of the loop then).

Maybe Tk directly is possible directly, best option?) or Tkinter:

http://www.ehow.com/how_10015489_check-keypress-python.html


You could also easily access the OS dependent parts directly.. Might be 
enough for you, but please (someone) then make a package with that method, 
so it can be special-cased/extended with @Linux etc. (end eventually 
incorporated into Base..).

-- 
Palli.



[julia-users] Re: How to interrupt a loop with a keyboard keystroke

2015-11-10 Thread Cedric St-Jean
Couldn't you periodically (every N iterations) save the array to disk? Or 
even better, put it in a global variable?

On Tuesday, November 10, 2015 at 5:07:17 AM UTC-5, Felipe Jiménez wrote:
>
> I have a long loop going. It solves a solitaire board-game by brute force 
> search, and depending on the initial configuration it could take seconds or 
> years to finish, I never know.
>
> I would like to be able to interrupt the loop at any time and save its 
> state (basically the values in an Array the loop operates on). That would 
> allow me to resume the loop later from where it left, instead of starting 
> all over again.
>
> Of course Ctrl-C is no good because I lose the state of the loop. My idea 
> is something like:
>
>while true
>   # do stuff #
>   if (keyboard was pressed) && (key was 'p')  # for "pause"
>  save Array to hard disk
>  return
>   end
>end
>
> But I don't know how to check if "keyboard was pressed" and what key it 
> was. I cannot use  chomp(readline())  because this waits until the user 
> hits Enter, which stops the loop going (unless I leave a spoon pressing the 
> Enter key :-). I need something that looks at the keyboard stack to see if 
> a key was recently pressed, and if none was pressed, it does nothing and 
> lets the loop continue without delay.
>
> I normally work at the REPL.
>
> Any ideas?
>
> Like always, sorry if my Q is too basic, but I did check the documentation 
> and the web and could not solve it.
> And a big thank you to the Julia developers and community. I am loving it.
>


[julia-users] Re: How to interrupt a loop with a keyboard keystroke

2015-11-10 Thread Felipe Jiménez
Thank you, Palli and Cedri.

Palli's answer shows it's not as easy as I thought. Cedric's answer is 
practical without overkill, so I'll go that way by now.

Still if someone writes a Julia readchar() or readkey() function that is 
similar to readline() but does not wait for Enter to be pressed, I am sure 
many people will find it useful!


[julia-users] Median filter

2015-11-10 Thread Rajn
I was wondering if a 'median filter' algorithm is available in Julia? There 
was some discussion on this topic in 2013. Wonder if someone built it 
eventually. I am looking for something similar to medflt1 of Matlab.
Thanks


[julia-users] Getting length of step range in function.

2015-11-10 Thread Ben Ward
Hi,

You can get the length of a StepRange:

*julia> **length(2:1:9)*

*8*

But if I try to do so inside a function I get an error about not finding a 
call method:

*julia> **function myfun(width::Int, step::Int, length::Int)*

   *clip = Int(floor(width / 2))*

   *start = 1 + clip*

   *stop = length - clip*

   *range = StepRange(start, step, stop)*

   *return length(range)*

   *end*

*myfun (generic function with 1 method)*



*julia> **myfun(3, 1, 10)*

*ERROR: MethodError: `call` has no method matching call(::Int64, 
::StepRange{Int64,Int64})*

Closest candidates are:

  BoundsError()

  BoundsError(*::Any...*)

  DivideError()

  ...

 in myfun at none:6

I don't know why this is, the range constructed with the function call 
`myfun(3,1,10` should be the same range as 2:1:9. Why is this happening?

Thanks,
Ben.


[julia-users] how to specify degrees of freedom for OneSampleTTest?

2015-11-10 Thread Evan
I want to do the following with some time series data:

Calculate 95% confidence interval for mean defined as +/-sigma(x)qt(0.025, 
N*-1) / sqrt(N*) where sigma(x) is the standard deviation at any point x 
and qt(0.025, N*-1) is the 2.5 percentage point of the Student-t 
distribution with N*-1 degrees of freedom.

I have been trying to do this with HypothesisTests' ci() and 
OneSampleTTest() functions, but as far as I can see OneSampleTTest() does 
not allow me to choose the number of degrees of freedom.

julia> t = OneSampleTTest(arr)
One sample t-test
-
Population details:
parameter of interest:   Mean
value under h_0: 0
point estimate:  0.3835
95% confidence interval: (0.14217301685460967,0.6248269831453903)

Test summary:
outcome with 95% confidence: reject h_0
two-sided p-value:   0.0057946078675091515 (very significant)

Details:
number of observations:   10
t-statistic:  3.5948622927526235
degrees of freedom:   9
empirical standard error: 0.10668002520517972


julia> t.df
9
julia> ci(t, 0.025, tail=:both)
(0.09706297518543938,0.6699370248145606)


Can anybody point me in the right direction?





Re: [julia-users] Getting length of step range in function.

2015-11-10 Thread Yichao Yu
On Tue, Nov 10, 2015 at 9:37 AM, Ben Ward  wrote:
> Hi,
>
> You can get the length of a StepRange:
>
> julia> length(2:1:9)
>
>
> 8
>
>
> But if I try to do so inside a function I get an error about not finding a
> call method:
>
> julia> function myfun(width::Int, step::Int, length::Int)


^

You override the value of `length`here.

>
>
>clip = Int(floor(width / 2))
>
>
>start = 1 + clip
>
>
>stop = length - clip
>
>
>range = StepRange(start, step, stop)
>
>
>return length(range)
>
>
>end
>
>
> myfun (generic function with 1 method)
>
>
>
>
> julia> myfun(3, 1, 10)
>
>
> ERROR: MethodError: `call` has no method matching call(::Int64,
> ::StepRange{Int64,Int64})
>
>
> Closest candidates are:
>
>
>   BoundsError()
>
>
>   BoundsError(::Any...)
>
>
>   DivideError()
>
>
>   ...
>
>
>  in myfun at none:6
>
>
> I don't know why this is, the range constructed with the function call
> `myfun(3,1,10` should be the same range as 2:1:9. Why is this happening?
>
> Thanks,
> Ben.


Re: [julia-users] Getting length of step range in function.

2015-11-10 Thread Tom Breloff
To be a little more explicit.  You are "masking" the function `Base.length`
with your local variable `length`.  So when you write `length(range)` you
are trying to "call" your local variable like it's a function.

On Tue, Nov 10, 2015 at 9:47 AM, Yichao Yu  wrote:

> On Tue, Nov 10, 2015 at 9:37 AM, Ben Ward 
> wrote:
> > Hi,
> >
> > You can get the length of a StepRange:
> >
> > julia> length(2:1:9)
> >
> >
> > 8
> >
> >
> > But if I try to do so inside a function I get an error about not finding
> a
> > call method:
> >
> > julia> function myfun(width::Int, step::Int, length::Int)
>
>
> ^
>
> You override the value of `length`here.
>
> >
> >
> >clip = Int(floor(width / 2))
> >
> >
> >start = 1 + clip
> >
> >
> >stop = length - clip
> >
> >
> >range = StepRange(start, step, stop)
> >
> >
> >return length(range)
> >
> >
> >end
> >
> >
> > myfun (generic function with 1 method)
> >
> >
> >
> >
> > julia> myfun(3, 1, 10)
> >
> >
> > ERROR: MethodError: `call` has no method matching call(::Int64,
> > ::StepRange{Int64,Int64})
> >
> >
> > Closest candidates are:
> >
> >
> >   BoundsError()
> >
> >
> >   BoundsError(::Any...)
> >
> >
> >   DivideError()
> >
> >
> >   ...
> >
> >
> >  in myfun at none:6
> >
> >
> > I don't know why this is, the range constructed with the function call
> > `myfun(3,1,10` should be the same range as 2:1:9. Why is this happening?
> >
> > Thanks,
> > Ben.
>


[julia-users] Re: Google releases TensorFlow as open source

2015-11-10 Thread Ben Moran
I'm very interested in this.  I haven't gone through the details yet but 
they say that C++ API currently only supports a subset of the Python API 
(weird!).

One possibility is to use PyCall to wrap the Python version, like was done 
for PyPlot, SymPy and like I began tentatively for Theano here - 
https://github.com/benmoran/MochaTheano.jl

On Monday, 9 November 2015 21:06:41 UTC, Phil Tomson wrote:
>
> Looks like they used SWIG to create the Python bindings.  I don't see 
> Julia listed as an output target for SWIG.
>
>
>
> On Monday, November 9, 2015 at 1:02:36 PM UTC-8, Phil Tomson wrote:
>>
>> Google has released it's deep learning library called TensorFlow as open 
>> source code:
>>
>> https://github.com/tensorflow/tensorflow
>>
>> They include Python bindings, Any ideas about how easy/difficult it would 
>> be to create Julia bindings?
>>
>> Phil
>>
>

[julia-users] Re: Chi square test in Julia?

2015-11-10 Thread Joshua Duncan
I found your Chi-Square test and am trying to use it.  It appears to work 
with one array but not with two.  My steps are below:

This works:
ChisqTest([1,2,3,4])

This doesn't:
ChisqTest([1,2,3,4],[1,2,2,4])

It errors with the following:

LoadError: MethodError: `ChisqTest` has no method matching 
ChisqTest(::Array{Int64,1}, ::Array{Int64,1})
Closest candidates are:
  ChisqTest{T<:Integer}(::AbstractArray{T<:Integer,1}, 
::AbstractArray{T<:Integer,1}, 
!Matched::Tuple{UnitRange{T<:Integer},UnitRange{T<:Integer}})
  ChisqTest{T<:Integer}(::AbstractArray{T<:Integer,1}, 
::AbstractArray{T<:Integer,1}, !Matched::T<:Integer)
  ChisqTest{T<:Integer,U<:AbstractFloat}(::AbstractArray{T<:Integer,1}, 
!Matched::Array{U<:AbstractFloat,1})
  ...
while loading In[118], in expression starting on line 1



I have checked the arrays to make sure they're AbstractArrays and the 
result is true.

Any advice would be helpful, I might just be implementing wrong.

On Friday, March 6, 2015 at 7:58:20 AM UTC-6, Benjamin Deonovic wrote:
>
> My pull has been merged: https://github.com/JuliaStats/HypothesisTests.jl
>
> On Thursday, March 5, 2015 at 8:32:32 AM UTC-6, Benjamin Deonovic wrote:
>>
>> I implemented the chisquare test in julia. I made a pull request in the 
>> HypothesisTests package. It hasn't been pulled yet, but probably will be 
>> soon. 
>>
>> On Sunday, February 8, 2015 at 5:32:48 PM UTC-6, Arin Basu wrote:
>>>
>>> Hi All,
>>>
>>> Please pardon my ignorance, but how does one do chisquare test in Julia. 
>>> Something like,
>>>
>>> ```
>>>
>>> chisq.test(x, y = NULL, correct = TRUE,
>>>p = rep(1/length(x), length(x)), rescale.p = FALSE,
>>>simulate.p.value = FALSE, B = 2000)
>>>
>>> ```
>>>
>>> in R
>>>
>>>
>>> I could not find anything in the documentation. I must not have searched 
>>> enough, what can it be?
>>>
>>>
>>> Best,
>>>
>>> Arin
>>>
>>>

Re: [julia-users] Re: Google releases TensorFlow as open source

2015-11-10 Thread Tom Breloff
I'm interested as well.  Who wants to claim TensorFlow.jl?

On Tue, Nov 10, 2015 at 9:11 AM, Ben Moran  wrote:

> I'm very interested in this.  I haven't gone through the details yet but
> they say that C++ API currently only supports a subset of the Python API
> (weird!).
>
> One possibility is to use PyCall to wrap the Python version, like was done
> for PyPlot, SymPy and like I began tentatively for Theano here -
> https://github.com/benmoran/MochaTheano.jl
>
>
> On Monday, 9 November 2015 21:06:41 UTC, Phil Tomson wrote:
>>
>> Looks like they used SWIG to create the Python bindings.  I don't see
>> Julia listed as an output target for SWIG.
>>
>>
>>
>> On Monday, November 9, 2015 at 1:02:36 PM UTC-8, Phil Tomson wrote:
>>>
>>> Google has released it's deep learning library called TensorFlow as open
>>> source code:
>>>
>>> https://github.com/tensorflow/tensorflow
>>>
>>> They include Python bindings, Any ideas about how easy/difficult it
>>> would be to create Julia bindings?
>>>
>>> Phil
>>>
>>


[julia-users] Re: how to specify degrees of freedom for OneSampleTTest?

2015-11-10 Thread j verzani
If you have the sample data, it is just the length of the data minus 1, so 
does not need to be specified, as it is computed.

On Tuesday, November 10, 2015 at 9:47:43 AM UTC-5, Evan wrote:
>
> I want to do the following with some time series data:
>
> Calculate 95% confidence interval for mean defined as +/-sigma(x)qt(0.025, 
> N*-1) / sqrt(N*) where sigma(x) is the standard deviation at any point x 
> and qt(0.025, N*-1) is the 2.5 percentage point of the Student-t 
> distribution with N*-1 degrees of freedom.
>
> I have been trying to do this with HypothesisTests' ci() and 
> OneSampleTTest() functions, but as far as I can see OneSampleTTest() does 
> not allow me to choose the number of degrees of freedom.
>
> julia> t = OneSampleTTest(arr)
> One sample t-test
> -
> Population details:
> parameter of interest:   Mean
> value under h_0: 0
> point estimate:  0.3835
> 95% confidence interval: (0.14217301685460967,0.6248269831453903)
>
> Test summary:
> outcome with 95% confidence: reject h_0
> two-sided p-value:   0.0057946078675091515 (very significant)
>
> Details:
> number of observations:   10
> t-statistic:  3.5948622927526235
> degrees of freedom:   9
> empirical standard error: 0.10668002520517972
>
>
> julia> t.df
> 9
> julia> ci(t, 0.025, tail=:both)
> (0.09706297518543938,0.6699370248145606)
>
>
> Can anybody point me in the right direction?
>
>
>
>

[julia-users] Re: How to interrupt a loop with a keyboard keystroke

2015-11-10 Thread Cedric St-Jean
This works too:

try
while true
end
catch x
if isa(x, InterruptException)
return array
end
end

On Tuesday, November 10, 2015 at 8:23:47 AM UTC-5, Felipe Jiménez wrote:
>
> Thank you, Palli and Cedri.
>
> Palli's answer shows it's not as easy as I thought. Cedric's answer is 
> practical without overkill, so I'll go that way by now.
>
> Still if someone writes a Julia readchar() or readkey() function that is 
> similar to readline() but does not wait for Enter to be pressed, I am sure 
> many people will find it useful!
>


[julia-users] Re: Google releases TensorFlow as open source

2015-11-10 Thread Randy Zwitch
For me, the bigger question is how does TensorFlow fit in/fill in gaps in 
currently available Julia libraries? I'm not saying that someone who is 
sufficiently interested shouldn't wrap the library, but it'd be great to 
identify what major gaps remain in ML for Julia and figure out if 
TensorFlow is the right way to proceed. 

We're certainly nowhere near the R duplication problem yet, but certainly 
we're already repeating ourselves in many areas.

On Monday, November 9, 2015 at 4:02:36 PM UTC-5, Phil Tomson wrote:
>
> Google has released it's deep learning library called TensorFlow as open 
> source code:
>
> https://github.com/tensorflow/tensorflow
>
> They include Python bindings, Any ideas about how easy/difficult it would 
> be to create Julia bindings?
>
> Phil
>


Re: [julia-users] Google releases TensorFlow as open source

2015-11-10 Thread Stefan Karpinski
Time for a JuliaML org?

On Tuesday, November 10, 2015, Tom Breloff  wrote:

> I'm interested as well.  Who wants to claim TensorFlow.jl?
>
> On Tue, Nov 10, 2015 at 9:11 AM, Ben Moran  > wrote:
>
>> I'm very interested in this.  I haven't gone through the details yet but
>> they say that C++ API currently only supports a subset of the Python API
>> (weird!).
>>
>> One possibility is to use PyCall to wrap the Python version, like was
>> done for PyPlot, SymPy and like I began tentatively for Theano here -
>> https://github.com/benmoran/MochaTheano.jl
>>
>>
>> On Monday, 9 November 2015 21:06:41 UTC, Phil Tomson wrote:
>>>
>>> Looks like they used SWIG to create the Python bindings.  I don't see
>>> Julia listed as an output target for SWIG.
>>>
>>>
>>>
>>> On Monday, November 9, 2015 at 1:02:36 PM UTC-8, Phil Tomson wrote:

 Google has released it's deep learning library called TensorFlow as
 open source code:

 https://github.com/tensorflow/tensorflow

 They include Python bindings, Any ideas about how easy/difficult it
 would be to create Julia bindings?

 Phil

>>>
>


[julia-users] Fill below a density plot with color in Winston

2015-11-10 Thread milktrader
Suppose you have a density plot ...

using Winston, KernelDensity

k = kde(rand(100))

Winston.plot(k)

Which would look something similar to this:


1) How can you fill below the curve with color? The two candidates 
for available methods include FillBelow()and FillBetween().

2) Is it then possible to fill below the curve from 0:0.5 with one color 
and below the curve from 0.5:1 with another color?


Re: [julia-users] Re: How to interrupt a loop with a keyboard keystroke

2015-11-10 Thread Páll Haraldsson


On þri 10.nóv 2015 12:03, Páll Haraldsson wrote:

The only game library I know available to Julia is kind of an overkill..:

https://github.com/zyedidia/SFML.jl

But this is something (a wrapper for a C++ game library) they have to
deal with (and much more..) and you could even let a joystick [button]
exit your loop..


You could use this or someone could extract (only) the low-level 
keyboard code..:



Ironically I could get the library installed, got some spinning graphics 
examples in a Window, but couldn't get checking keyboard status to work 
at first :)


Just follow the main README, also "install the package libsfml-dev which 
will also install all dependencies" (that are 46 MB) if on Linux. On 
Windows everything seems handled, and I also saw some OS X specific code.




Anyway, after trying this example also (also copy-pasting it to the REPL):

https://github.com/zyedidia/SFML.jl/blob/master/examples/Graphics/pong.jl


I got this to work:

[This works for me on Linux, after the graphics window is gone]


#38=left SHIFT, see the file above

julia> is_key_pressed(38)
false

julia> is_key_pressed(38) #while pressing left SHIFT
true



https://github.com/zyedidia/SFML.jl/blob/master/src/julia/Window/keyboard.jl

function is_key_pressed(key::Int)
return ccall((:sfKeyboard_isKeyPressed, libcsfml_window), Int32, 
(Int32,), key) == 1

end

baremodule KeyCode
const UNKNOWN = -1
const A = 0
const B = 1

[..]


First I made an error with just copy-pasting this:

julia> ccall((:sfKeyboard_isKeyPressed, libcsfml_window), Int32, 
(Int32,), key) == 1

ERROR: UndefVarError: key not defined
 in anonymous at no file


This still doesn't work (while the is_key_pressed(38) function works 
because of libcsfml_window that is not avaiable to me from the REPL):


julia> ccall((:sfKeyboard_isKeyPressed, libcsfml_window), Int32, 
(Int32,), 38) == 1

ERROR: UndefVarError: libcsfml_window not defined
 in anonymous at no file


[julia-users] Re: Median filter

2015-11-10 Thread Dan
As a quick stopgap, you could use the following:

medianfilter1(v,ws) = [median(v[i:(i+ws-1)]) for i=1:(length(v)-ws+1)]

medianfilter(v) = medianfilter1(vcat(0,v,0),3)


`medianfilter` does a 3 window median filter. It is not the fastest 
implementation, but it works (hopefully). 

On Tuesday, November 10, 2015 at 4:31:42 PM UTC+2, Rajn wrote:
>
> I was wondering if a 'median filter' algorithm is available in Julia? 
> There was some discussion on this topic in 2013. Wonder if someone built it 
> eventually. I am looking for something similar to medflt1 of Matlab.
> Thanks
>


[julia-users] Re: Fill below a density plot with color in Winston

2015-11-10 Thread milktrader
To answer question #1 only, this works ...

using Winston, KernelDensity

k = kde(rand(100))

fieldnames(k)

# outputs ...

# 2-element Array{Symbol,1}:
# :x  
# :density

f = FillBelow(k.x, k.density, color="blue")
p = FramedPlot()
add(p,f)















So now the only question is how to split this into two colors.







On Tuesday, November 10, 2015 at 11:55:20 AM UTC-5, milktrader wrote:
>
> Suppose you have a density plot ...
>
> using Winston, KernelDensity
>
> k = kde(rand(100))
>
> Winston.plot(k)
>
> Which would look something similar to this:
>
>
> 
> 1) How can you fill below the curve with color? The two candidates 
> for available methods include FillBelow()and FillBetween().
>
> 2) Is it then possible to fill below the curve from 0:0.5 with one color 
> and below the curve from 0.5:1 with another color?
>


[julia-users] Re: Fill below a density plot with color in Winston

2015-11-10 Thread milktrader


> The solution to the two-color problem is ...
>

using Winston, KernelDensity
 
k = kde(rand(100))

k1 = k.x[k.x .< .5];

k2 = k.x[k.x .> .5];

f1 = FillBelow(k1, k.density[1:length(k1)], color="blue");

f2 = FillBelow(k2, k.density[length(k1)+1:end], color="red");

p = FramedPlot()

add(p, f1, f2)





[julia-users] Re: Fill below a density plot with color in Winston

2015-11-10 Thread milktrader
I'll be honest, the code to do this in R is substantially more 
non-intuitive. Nice work Mike!

On Tuesday, November 10, 2015 at 12:51:32 PM UTC-5, milktrader wrote:
>
>
> The solution to the two-color problem is ...
>>
>
> using Winston, KernelDensity
>  
> k = kde(rand(100))
>
> k1 = k.x[k.x .< .5];
>
> k2 = k.x[k.x .> .5];
>
> f1 = FillBelow(k1, k.density[1:length(k1)], color="blue");
>
> f2 = FillBelow(k2, k.density[length(k1)+1:end], color="red");
>
> p = FramedPlot()
>
> add(p, f1, f2)
>
>
> 
>
>

Re: [julia-users] Google releases TensorFlow as open source

2015-11-10 Thread Steve Kelly
FWIW I think this may be the C API:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/public/tensor_c_api.h
On Nov 10, 2015 11:05 AM, "Stefan Karpinski"  wrote:

> Time for a JuliaML org?
>
> On Tuesday, November 10, 2015, Tom Breloff  wrote:
>
>> I'm interested as well.  Who wants to claim TensorFlow.jl?
>>
>> On Tue, Nov 10, 2015 at 9:11 AM, Ben Moran  wrote:
>>
>>> I'm very interested in this.  I haven't gone through the details yet but
>>> they say that C++ API currently only supports a subset of the Python API
>>> (weird!).
>>>
>>> One possibility is to use PyCall to wrap the Python version, like was
>>> done for PyPlot, SymPy and like I began tentatively for Theano here -
>>> https://github.com/benmoran/MochaTheano.jl
>>>
>>>
>>> On Monday, 9 November 2015 21:06:41 UTC, Phil Tomson wrote:

 Looks like they used SWIG to create the Python bindings.  I don't see
 Julia listed as an output target for SWIG.



 On Monday, November 9, 2015 at 1:02:36 PM UTC-8, Phil Tomson wrote:
>
> Google has released it's deep learning library called TensorFlow as
> open source code:
>
> https://github.com/tensorflow/tensorflow
>
> They include Python bindings, Any ideas about how easy/difficult it
> would be to create Julia bindings?
>
> Phil
>

>>


Re: [julia-users] Google releases TensorFlow as open source

2015-11-10 Thread milktrader
Yep +1

On Tuesday, November 10, 2015 at 11:05:05 AM UTC-5, Stefan Karpinski wrote:
>
> Time for a JuliaML org?
>
> On Tuesday, November 10, 2015, Tom Breloff > 
> wrote:
>
>> I'm interested as well.  Who wants to claim TensorFlow.jl?
>>
>> On Tue, Nov 10, 2015 at 9:11 AM, Ben Moran  wrote:
>>
>>> I'm very interested in this.  I haven't gone through the details yet but 
>>> they say that C++ API currently only supports a subset of the Python API 
>>> (weird!).
>>>
>>> One possibility is to use PyCall to wrap the Python version, like was 
>>> done for PyPlot, SymPy and like I began tentatively for Theano here - 
>>> https://github.com/benmoran/MochaTheano.jl
>>>
>>>
>>> On Monday, 9 November 2015 21:06:41 UTC, Phil Tomson wrote:

 Looks like they used SWIG to create the Python bindings.  I don't see 
 Julia listed as an output target for SWIG.



 On Monday, November 9, 2015 at 1:02:36 PM UTC-8, Phil Tomson wrote:
>
> Google has released it's deep learning library called TensorFlow as 
> open source code:
>
> https://github.com/tensorflow/tensorflow
>
> They include Python bindings, Any ideas about how easy/difficult it 
> would be to create Julia bindings?
>
> Phil
>

>>

[julia-users] Re: PyPlot won't close first figure drawn

2015-11-10 Thread lewis
I'd still really like help with this.

Here are some possible problems with the way just the first figure is being 
handled within PyPlot:
 1.being put in the figure_queue, which holds figures for IJulia--this 
shouldn't be happening as I am not using IJulia in this case;
 2.   somehow matplotlib is losing it: the close() function in PyPlot is a 
straightforward pycall to put[:close]--with a figure argument f.  But, when 
you plot without defining a figure first there is no figure to reference. 
 Calls to close don't pass any argument.  It's not clear why this would be 
a problem because everything works for the 2nd and all subsequent plots 
created WITHOUT first starting an identified figure.  
3.  gcf() can't find the figure.  When I run gcf after the first plot, it 
actually creates a NEW figure because it doesn't see that any figure exists 
(even though it is there because matplotlib created it and it's on the 
screen in a tk window).

So, number 3 seems to point to the symptom that in the handoff between 
matplotlib and pyplot, the first figure created is getting lost.  Perhaps 
someone can point me to the next level so I can keep trying to diagnose 
this.

It seems folks aren't so interested in problems that are rarely seen and 
are reported by Noobs.  We were all once noobs. I may be a permanent noob. 
 I realize there are cooler things to focus on in the future trajectory of 
Julia, but this is an actual problem.
  

On Monday, November 9, 2015 at 11:07:50 AM UTC-8, Ethan Anderes wrote:
>
> I have noticed something similar. 
>
> For example, if I do:
>
> julia> using PyPlot
>
> julia> figure(1)
>
> julia> plot(sin(1:10))
>
> julia> figure(2)
>
> julia> plot(cos(1:10))
>
> then close the first figure (by clicking the red button with my mouse) I 
> get a spinning beach ball. I’m on OSX 10.11.1 using Anaconda python. PyPlot 
> is at version "PyPlot"=>v"2.1.1+" and my system info is
>
> julia> versioninfo()
> Julia Version 0.4.1-pre+16
> Commit 2cdef5d (2015-10-24 06:33 UTC)
> Platform Info:
>   System: Darwin (x86_64-apple-darwin15.0.0)
>   CPU: Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
>   WORD_SIZE: 64
>   BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
>   LAPACK: libopenblas64_
>   LIBM: libopenlibm
>   LLVM: libLLVM-3.3
>
>
> ​
>


Re: [julia-users] WinRPM fails to install for fresh Julia 0.4.0 installation on Windows

2015-11-10 Thread jpclemens0

   _
   _   _ _(_)_ |  A fresh approach to technical computing
  (_) | (_) (_)|  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.0 (2015-10-08 06:20 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/   |  x86_64-w64-mingw32

julia> Pkg.update()
INFO: Initializing package repository C:\Users\clemenj2\.julia\v0.4
INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl
INFO: Updating METADATA...
INFO: Computing changes...
INFO: No packages to install, update or remove

julia> Pkg.add("IJulia")
INFO: Cloning cache of BinDeps from 
git://github.com/JuliaLang/BinDeps.jl.git
INFO: Cloning cache of Compat from git://github.com/JuliaLang/Compat.jl.git
INFO: Cloning cache of Conda from git://github.com/Luthaf/Conda.jl.git
INFO: Cloning cache of IJulia from git://github.com/JuliaLang/IJulia.jl.git
INFO: Cloning cache of JSON from git://github.com/JuliaLang/JSON.jl.git
INFO: Cloning cache of LibExpat from 
git://github.com/amitmurthy/LibExpat.jl.git

INFO: Cloning cache of Nettle from 
git://github.com/staticfloat/Nettle.jl.git
INFO: Cloning cache of SHA from git://github.com/staticfloat/SHA.jl.git
INFO: Cloning cache of URIParser from 
git://github.com/JuliaWeb/URIParser.jl.git

INFO: Cloning cache of WinRPM from git://github.com/JuliaLang/WinRPM.jl.git
INFO: Cloning cache of ZMQ from git://github.com/JuliaLang/ZMQ.jl.git
INFO: Cloning cache of Zlib from git://github.com/dcjones/Zlib.jl.git
INFO: Installing BinDeps v0.3.19
INFO: Installing Compat v0.7.7
INFO: Installing Conda v0.1.8
INFO: Installing IJulia v1.1.8
INFO: Installing JSON v0.5.0
INFO: Installing LibExpat v0.1.0
INFO: Installing Nettle v0.2.0
INFO: Installing SHA v0.1.2
INFO: Installing URIParser v0.1.1
INFO: Installing WinRPM v0.1.13
INFO: Installing ZMQ v0.3.0
INFO: Installing Zlib v0.1.12
INFO: Building WinRPM
INFO: Precompiling module Compat...
INFO: Precompiling module URIParser...
INFO: Precompiling module SHA...
WARNING: skipping repodata/repomd.xml, not in cache -- call WinRPM.update() 
to d
ownload
WARNING: skipping repodata/repomd.xml, not in cache -- call WinRPM.update() 
to d
ownload
INFO: Downloading 
https://cache.e.ip.saba.us/http://download.opensuse.org/reposi
tories/windows:/mingw:/win32/openSUSE_13.2/repodata/repomd.xml
INFO: Downloading 
https://cache.e.ip.saba.us/http://download.opensuse.org/reposi
tories/windows:/mingw:/win32/openSUSE_13.2/repodata/859a79e1edfe19162ec05cb0a736
196feb8df2ea889738c3cfeab5d970c35fd7-primary.xml.gz
WARNING: Unknown download failure, error code: 2148270088
WARNING: Retry 1/5 downloading: 
https://cache.e.ip.saba.us/http://download.opens
use.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/859a79e1edfe19
162ec05cb0a736196feb8df2ea889738c3cfeab5d970c35fd7-primary.xml.gz
WARNING: Unknown download failure, error code: 2148270088
WARNING: Retry 2/5 downloading: 
https://cache.e.ip.saba.us/http://download.opens
use.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/859a79e1edfe19
162ec05cb0a736196feb8df2ea889738c3cfeab5d970c35fd7-primary.xml.gz
WARNING: Unknown download failure, error code: 2148270088
WARNING: Retry 3/5 downloading: 
https://cache.e.ip.saba.us/http://download.opens
use.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/859a79e1edfe19
162ec05cb0a736196feb8df2ea889738c3cfeab5d970c35fd7-primary.xml.gz
WARNING: Unknown download failure, error code: 2148270088
WARNING: Retry 4/5 downloading: 
https://cache.e.ip.saba.us/http://download.opens
use.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/859a79e1edfe19
162ec05cb0a736196feb8df2ea889738c3cfeab5d970c35fd7-primary.xml.gz
WARNING: Unknown download failure, error code: 2148270088
WARNING: Retry 5/5 downloading: 
https://cache.e.ip.saba.us/http://download.opens
use.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/859a79e1edfe19
162ec05cb0a736196feb8df2ea889738c3cfeab5d970c35fd7-primary.xml.gz
WARNING: received error 0 while downloading 
https://cache.e.ip.saba.us/http://do
wnload.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_13.2/repodata/85
9a79e1edfe19162ec05cb0a736196feb8df2ea889738c3cfeab5d970c35fd7-primary.xml.gz
INFO: Downloading 
https://cache.e.ip.saba.us/http://download.opensuse.org/reposi
tories/windows:/mingw:/win64/openSUSE_13.2/repodata/repomd.xml
INFO: Downloading 
https://cache.e.ip.saba.us/http://download.opensuse.org/reposi
tories/windows:/mingw:/win64/openSUSE_13.2/repodata/0fd5b889317a51ad1bb2d276d4d5
ea68183c9fa8b97e245da8720c06c2ef213f-primary.xml.gz
WARNING: Unknown download failure, error code: 2148270088
WARNING: Retry 1/5 downloading: 
https://cache.e.ip.saba.us/http://download.opens
use.org/repositories/windows:/mingw:/win64/openSUSE_13.2/repodata/0fd5b889317a51
ad1bb2d276d4d5ea68183c9fa8b97e245da8720c06c2ef213f-primary.xml.gz
WARNING: Unknown download failure, error code: 2

Re: [julia-users] Re: PyPlot won't close first figure drawn

2015-11-10 Thread Tom Breloff
Lewis:  There are a couple things to note:

   - This belongs as a PyPlot issue... it's not really appropriate for
   julia-users
   - I think people have been slow to help you, not because you're a
   "noob", but because of your extreme negativity so far.

You've spent enough time on this that you're probably also the most
qualified to solve it.

On Tue, Nov 10, 2015 at 1:34 PM,  wrote:

> I'd still really like help with this.
>
> Here are some possible problems with the way just the first figure is
> being handled within PyPlot:
>  1.being put in the figure_queue, which holds figures for IJulia--this
> shouldn't be happening as I am not using IJulia in this case;
>  2.   somehow matplotlib is losing it: the close() function in PyPlot is a
> straightforward pycall to put[:close]--with a figure argument f.  But, when
> you plot without defining a figure first there is no figure to reference.
> Calls to close don't pass any argument.  It's not clear why this would be a
> problem because everything works for the 2nd and all subsequent plots
> created WITHOUT first starting an identified figure.
> 3.  gcf() can't find the figure.  When I run gcf after the first plot, it
> actually creates a NEW figure because it doesn't see that any figure exists
> (even though it is there because matplotlib created it and it's on the
> screen in a tk window).
>
> So, number 3 seems to point to the symptom that in the handoff between
> matplotlib and pyplot, the first figure created is getting lost.  Perhaps
> someone can point me to the next level so I can keep trying to diagnose
> this.
>
> It seems folks aren't so interested in problems that are rarely seen and
> are reported by Noobs.  We were all once noobs. I may be a permanent noob.
> I realize there are cooler things to focus on in the future trajectory of
> Julia, but this is an actual problem.
>
>
> On Monday, November 9, 2015 at 11:07:50 AM UTC-8, Ethan Anderes wrote:
>>
>> I have noticed something similar.
>>
>> For example, if I do:
>>
>> julia> using PyPlot
>>
>> julia> figure(1)
>>
>> julia> plot(sin(1:10))
>>
>> julia> figure(2)
>>
>> julia> plot(cos(1:10))
>>
>> then close the first figure (by clicking the red button with my mouse) I
>> get a spinning beach ball. I’m on OSX 10.11.1 using Anaconda python. PyPlot
>> is at version "PyPlot"=>v"2.1.1+" and my system info is
>>
>> julia> versioninfo()
>> Julia Version 0.4.1-pre+16
>> Commit 2cdef5d (2015-10-24 06:33 UTC)
>> Platform Info:
>>   System: Darwin (x86_64-apple-darwin15.0.0)
>>   CPU: Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
>>   WORD_SIZE: 64
>>   BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
>>   LAPACK: libopenblas64_
>>   LIBM: libopenlibm
>>   LLVM: libLLVM-3.3
>>
>>
>> ​
>>
>


Re: [julia-users] Re: PyPlot won't close first figure drawn

2015-11-10 Thread lewis
I posted as an issue over on PyPlot.  I got a reply about Python but not 
about the problem.

Please point out how I have been negative.  I've tried to provide 
information and one other user confirms that he has also seen the problem. 
 I thought I was being pretty clear to just ask for clues or pointers to 
other things I can try or look at it.

On Tuesday, November 10, 2015 at 10:50:04 AM UTC-8, Tom Breloff wrote:
>
> Lewis:  There are a couple things to note:
>
>- This belongs as a PyPlot issue... it's not really appropriate for 
>julia-users
>- I think people have been slow to help you, not because you're a 
>"noob", but because of your extreme negativity so far.
>
> You've spent enough time on this that you're probably also the most 
> qualified to solve it.
>
> On Tue, Nov 10, 2015 at 1:34 PM, > 
> wrote:
>
>> I'd still really like help with this.
>>
>> Here are some possible problems with the way just the first figure is 
>> being handled within PyPlot:
>>  1.being put in the figure_queue, which holds figures for 
>> IJulia--this shouldn't be happening as I am not using IJulia in this case;
>>  2.   somehow matplotlib is losing it: the close() function in PyPlot is 
>> a straightforward pycall to put[:close]--with a figure argument f.  But, 
>> when you plot without defining a figure first there is no figure to 
>> reference.  Calls to close don't pass any argument.  It's not clear why 
>> this would be a problem because everything works for the 2nd and all 
>> subsequent plots created WITHOUT first starting an identified figure.  
>> 3.  gcf() can't find the figure.  When I run gcf after the first plot, it 
>> actually creates a NEW figure because it doesn't see that any figure exists 
>> (even though it is there because matplotlib created it and it's on the 
>> screen in a tk window).
>>
>> So, number 3 seems to point to the symptom that in the handoff between 
>> matplotlib and pyplot, the first figure created is getting lost.  Perhaps 
>> someone can point me to the next level so I can keep trying to diagnose 
>> this.
>>
>> It seems folks aren't so interested in problems that are rarely seen and 
>> are reported by Noobs.  We were all once noobs. I may be a permanent noob.  
>> I realize there are cooler things to focus on in the future trajectory of 
>> Julia, but this is an actual problem.
>>   
>>
>> On Monday, November 9, 2015 at 11:07:50 AM UTC-8, Ethan Anderes wrote:
>>>
>>> I have noticed something similar. 
>>>
>>> For example, if I do:
>>>
>>> julia> using PyPlot
>>>
>>> julia> figure(1)
>>>
>>> julia> plot(sin(1:10))
>>>
>>> julia> figure(2)
>>>
>>> julia> plot(cos(1:10))
>>>
>>> then close the first figure (by clicking the red button with my mouse) I 
>>> get a spinning beach ball. I’m on OSX 10.11.1 using Anaconda python. PyPlot 
>>> is at version "PyPlot"=>v"2.1.1+" and my system info is
>>>
>>> julia> versioninfo()
>>> Julia Version 0.4.1-pre+16
>>> Commit 2cdef5d (2015-10-24 06:33 UTC)
>>> Platform Info:
>>>   System: Darwin (x86_64-apple-darwin15.0.0)
>>>   CPU: Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
>>>   WORD_SIZE: 64
>>>   BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
>>>   LAPACK: libopenblas64_
>>>   LIBM: libopenlibm
>>>   LLVM: libLLVM-3.3
>>>
>>>
>>> ​
>>>
>>
>

Re: [julia-users] Google releases TensorFlow as open source

2015-11-10 Thread Diego Javier Zea
+1 It would be good to have a *TensorFlow.jl*!


[julia-users] Re: Chi square test in Julia?

2015-11-10 Thread cormullion
Try a matrix?

[julia-users] Re: Chi square test in Julia?

2015-11-10 Thread Benjamin Deonovic
Hey Joshua,

Just saw your post. I will investigate into what the issue is. I wrote this 
quite a while ago when I was just learning Julia!

On Tuesday, November 10, 2015 at 9:10:10 AM UTC-6, Joshua Duncan wrote:
>
> I found your Chi-Square test and am trying to use it.  It appears to work 
> with one array but not with two.  My steps are below:
>
> This works:
> ChisqTest([1,2,3,4])
>
> This doesn't:
> ChisqTest([1,2,3,4],[1,2,2,4])
>
> It errors with the following:
>
> LoadError: MethodError: `ChisqTest` has no method matching 
> ChisqTest(::Array{Int64,1}, ::Array{Int64,1})
> Closest candidates are:
>   ChisqTest{T<:Integer}(::AbstractArray{T<:Integer,1}, 
> ::AbstractArray{T<:Integer,1}, 
> !Matched::Tuple{UnitRange{T<:Integer},UnitRange{T<:Integer}})
>   ChisqTest{T<:Integer}(::AbstractArray{T<:Integer,1}, 
> ::AbstractArray{T<:Integer,1}, !Matched::T<:Integer)
>   ChisqTest{T<:Integer,U<:AbstractFloat}(::AbstractArray{T<:Integer,1}, 
> !Matched::Array{U<:AbstractFloat,1})
>   ...
> while loading In[118], in expression starting on line 1
>
>
>
> I have checked the arrays to make sure they're AbstractArrays and the 
> result is true.
>
> Any advice would be helpful, I might just be implementing wrong.
>
> On Friday, March 6, 2015 at 7:58:20 AM UTC-6, Benjamin Deonovic wrote:
>>
>> My pull has been merged: https://github.com/JuliaStats/HypothesisTests.jl
>>
>> On Thursday, March 5, 2015 at 8:32:32 AM UTC-6, Benjamin Deonovic wrote:
>>>
>>> I implemented the chisquare test in julia. I made a pull request in the 
>>> HypothesisTests package. It hasn't been pulled yet, but probably will be 
>>> soon. 
>>>
>>> On Sunday, February 8, 2015 at 5:32:48 PM UTC-6, Arin Basu wrote:

 Hi All,

 Please pardon my ignorance, but how does one do chisquare test in 
 Julia. Something like,

 ```

 chisq.test(x, y = NULL, correct = TRUE,
p = rep(1/length(x), length(x)), rescale.p = FALSE,
simulate.p.value = FALSE, B = 2000)

 ```

 in R


 I could not find anything in the documentation. I must not have searched 
 enough, what can it be?


 Best,

 Arin



Re: [julia-users] Re: CUDART and CURAND problem on running the same "do" loop twice

2015-11-10 Thread Andrei Zh


> But I can replicate the bug if I use CURAND. I'd suggest filing an issue 
> with 
> that package. Most likely it needs to (and, you need to) initialize 
> resources 
> according to these instructions: 
> https://github.com/JuliaGPU/CUDArt.jl#initializing-and-freeing-ptx-modules 
>
>
CURAND.jl is a thin wrapper around the corresponding C library and doesn't 
use any custom modules, so I suppose initializing resources is not 
applicable to this case. 

Tim, except for loading utility functions (PtxUtils), is there anything 
special in `device() ... do` block that I should pay attention to? 


[julia-users] Re: Chi square test in Julia?

2015-11-10 Thread Benjamin Deonovic
Okay I have figured out the issue. I will fix it so it works the way you 
expected it to work. Before the fix goes live though it should work to do:

ChisqTest([1,2,3,4],[1,2,2,4], 4)

*note the 4

The issue was when I submitted the code to HypothesisTests.jl the only way 
to create a contingency table between two vectors x and y was to also 
provide the levels that the categorical variables could take on. Afterwards 
I submited a version to StatsBase.jl for ``counts`` that had default 
values, but I forgot to update my code at HypothesisTests.jl. Sorry for the 
late response!


**Note the above will give you what is equivalent in R to:

> chisq.test(matrix(c(1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,1),nrow = 4,ncol = 4))

Pearson's Chi-squared test

data:  matrix(c(1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1), nrow = 4, 
ncol = 4)
X-squared = NaN, df = 9, p-value = NA

Warning message:
In chisq.test(matrix(c(1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0,  :
  Chi-squared approximation may be incorrect



However you are probably interested in 

> chisq.test(c(1,2,3,4),c(1,2,2,4))

Pearson's Chi-squared test

data:  c(1, 2, 3, 4) and c(1, 2, 2, 4)
X-squared = 8, df = 6, p-value = 0.2381


When I wrote up the function there wasn't a good equivalent of R's 
``table`` function. I will try to flesh out this code so it works closer to 
R. In the meantime the best thing is to work with the full contingency 
table i.e.:

julia> ChisqTest([1 0 0; 0 1 0; 0 1 0; 0 0 1]) 
Pearson's Chi-square Test 
- 
Population details: 
 parameter of interest: Multinomial Probabilities 
 value under h_0: 
[0.0625,0.0625,0.0625,0.0625,0.125,0.125,0.125,0.125,0.0625,0.0625,0.0625,0.0625]
 
 point estimate: [0.25,0.0,0.0,0.0,0.0,0.25,0.25,0.0,0.0,0.0,0.0,0.25] 
 95% confidence interval: 
[(0.0,1.0),(0.0,1.0),(0.0,1.0),(0.0,1.0),(0.0,1.0),(0.0,1.0),(0.0,1.0),(0.0,1.0),(0.0,1.0),(0.0,1.0),(0.0,1.0),(0.0,1.0)]
 
 
Test summary: 
 outcome with 95% confidence: fail to reject h_0 
 two-sided p-value: 0.23810330555354436 (not significant) 
 
Details: 
 Sample size: 4 
 statistic: 8.0 
 degrees of freedom: 6 
 residuals: 
[1.5,-0.5,-0.5,-0.5,-0.7071067811865475,0.7071067811865475,0.7071067811865475,-0.7071067811865475,-0.5,-0.5,-0.5,1.5]
 
 std. residuals: 
[2.0,-0.,-0.,-0.,-1.1547005383792517,1.1547005383792517,1.1547005383792517,-1.1547005383792517,-0.,-0.66
66,-0.,2.0] 
 







[julia-users] Re: Chi square test in Julia?

2015-11-10 Thread Benjamin Deonovic
Looks like the state of Julia's "Factors" (PooledDataArrays) is still quite 
a fast evolving monster. Because of this there hasn't been a proper 
implementation of R's "table" function. For now, if you want to run 
ChisqTest in Julia on two vectors do it on the matrix you would obtain in R 
by running table(x,y). 


Re: [julia-users] Re: CUDART and CURAND problem on running the same "do" loop twice

2015-11-10 Thread Tim Holy
See the code in src/device.jl that implements the do-block syntax (especially 
functions that take a function as their first argument). It's not a big file, 
so 
shouldn't be too hard to figure out what's happening.

--Tim

On Tuesday, November 10, 2015 02:16:52 PM Andrei Zh wrote:
> > But I can replicate the bug if I use CURAND. I'd suggest filing an issue
> > with
> > that package. Most likely it needs to (and, you need to) initialize
> > resources
> > according to these instructions:
> > https://github.com/JuliaGPU/CUDArt.jl#initializing-and-freeing-ptx-modules
> 
> CURAND.jl is a thin wrapper around the corresponding C library and doesn't
> use any custom modules, so I suppose initializing resources is not
> applicable to this case.
> 
> Tim, except for loading utility functions (PtxUtils), is there anything
> special in `device() ... do` block that I should pay attention to?



[julia-users] Moore foundation grant.

2015-11-10 Thread Lampkld
Congratulations on the exciting news!

I have played around with Julia A bit and love the language , But Found Its 
Lacking Some robust stats/ml/data manipulation infrastructure. 

Can anyone tell me if these areas are slated  to be worked on from the grant 
money? I'm trying to get some foresight on the ecosystem so I can make some 
decisions to use Julia for some projects.

thanks !


[julia-users] Re: Google releases TensorFlow as open source

2015-11-10 Thread Alireza Nejati
If anyone draws up an initial implementation (or pathway to implementation, 
even), I'd gladly contribute. I think it's highly strategically important 
to have a julia interface to TensorFlow.


[julia-users] Re: Google releases TensorFlow as open source

2015-11-10 Thread Alireza Nejati
Randy: To answer your question, I'd reckon that the two major gaps in julia 
that TensorFlow could fill are:

1. Lack of automatic differentiation on arbitrary graph structures.
2. Lack of ability to map computations across cpus and clusters.

Funny enough, I was thinking about (1) for the past few weeks and I think I 
have an idea about how to accomplish it using existing JuliaDiff libraries. 
About (2), I have no idea, and that's probably going to be the most 
important aspect of TensorFlow moving forward (and also probably the 
hardest to implement). So for the time being, I think it's definitely 
worthwhile to just have an interface to TensorFlow. There are a few ways 
this could be done. Some ways that I can think of:

1. Just tell people to use PyCall directly. Not an elegant solution.
2. A more julia-integrated interface *a la* SymPy.
3. Using TensorFlow as the 'backend' of a novel julia-based machine 
learning library. In this scenario, everything would be in julia, and 
TensorFlow would only be used to map computations to hardware.

I think 3 is the most attractive option, but also probably the hardest to 
do.


[julia-users] Re: Google releases TensorFlow as open source

2015-11-10 Thread Valentin Churavy
It fits in the same niche that Mocha.jl and MXNet.jl are filling right now. 
MXNet is a ML library that shares many of the same design ideas of 
TensorFlow and has great Julia support https://github.com/dmlc/MXNet.jl


On Wednesday, 11 November 2015 01:04:00 UTC+9, Randy Zwitch wrote:
>
> For me, the bigger question is how does TensorFlow fit in/fill in gaps in 
> currently available Julia libraries? I'm not saying that someone who is 
> sufficiently interested shouldn't wrap the library, but it'd be great to 
> identify what major gaps remain in ML for Julia and figure out if 
> TensorFlow is the right way to proceed. 
>
> We're certainly nowhere near the R duplication problem yet, but certainly 
> we're already repeating ourselves in many areas.
>
> On Monday, November 9, 2015 at 4:02:36 PM UTC-5, Phil Tomson wrote:
>>
>> Google has released it's deep learning library called TensorFlow as open 
>> source code:
>>
>> https://github.com/tensorflow/tensorflow
>>
>> They include Python bindings, Any ideas about how easy/difficult it would 
>> be to create Julia bindings?
>>
>> Phil
>>
>

[julia-users] General help with concepts: splatting/slurping, inlining, tuple access, function chaining

2015-11-10 Thread 'Greg Plowman' via julia-users
I have some naïve and probably stupid questions about writing efficient 
code in Julia.
I almost didn't post this because I'm not sure if this is the right place 
for asking for this type of conceptual help. I do hope it is appropriate. I 
apologise in advance if it's not.

I have been trying to benchmark some code (using @time) but I'm coming up 
against several concepts I would like to understand better, and will no 
doubt help to better guide my hitherto "black box" approach.
These concepts are related in what I'm trying to understand, but 
understanding them separately might also help me.

   - splatting/slurping
   - inlining
   - tuple access
   - function chaining

Not really sure how to present my questions. 
Maybe first read through to *Separate Arguments vs Tuple* where all 
concepts seem to come into play and there are more direct questions.


*Splatting/Slurping*
I have read that splatting/slurping incurs a penalty. 
Is it the splatting or the slurping or both?
I have also read that this is not the case if the function is inlined. Is 
this true?

*Inlining*
How do I know if a function is inlined? 
When is it necessary to explicitly inline? (say with @inline, or 
Exrp(:meta, :inline)) 
Does this guarantee inlining, or is it just a hint to the compiler?
Is the compiler usually smart enough to inline optimally.
Why wouldn't I explicitly inline all my small functions?

*Overhead of accessing tuples compared to separate variables/arguments*
Is there overhead in accessing tuples vs separate arguments?
Is the expression assigned to x slower than expression assigned to y?
I = (1,2,3)
i1 = 1, i2 = 2, i3 = 3
x = I[1]+I[2]+I[3]
y = i1+i2+i3


*"Chained" function calls *(not sure if chained is the right word)
It seems sometimes I have lots of small "convenience" functions, 
effectively chained until a final "working" function is called.
A calls B calls C calls D calls ... calls Z. If A, B, C, ... are small 
(maybe getters, convenience functions etc), is this still efficient?
Is there any penalty for this?
How does this relate to inlining?
Presumably there is no penalty if and only if functions are inlined? Is 
this true?
If so, is there a limit to the number of levels (functions in call chain) 
that can be inlined?
Should I be worried about any of this?


So I guess all this comes together when trying to understand the following:

*Separate Arguments vs Tuple*
I have seen code where there are two forms of a function, one accepts a 
tuple, the other accepts separate arguments.

foo(I::Tuple{Vararg{Integer}) = (some code here) -OR- foo{N}(I::NTuple{N,
Integer}) = (some code here)
foo(I::Integer...) = foo(I)

Is calling foo((1,2,3)) more efficient than calling foo(1,2,3)?
It seems foo(1,2,3) requires a slurp and then calls foo((1,2,3)) anyway. 
Is there overhead in the slurp?
Is there overhead in the extra call, or will inlining remove the overhead?
If so, how do I know if it will be inlined automatically? Do I need to 
explicitly @inline or equivalent? 

Does defining foo as a function of a tuple incur tuple access overhead? 
Would it be faster to define a "primary" function with separate arguments 
and a convenience function with tuple argument?

bar(i1:Integer, i2::Integer, i3::Integer) = (some code here)
bar(I::NTuple{3,Integer) = foo(I...)

Is bar(i1,i2,i3) faster than foo(I) (simply because foo requires tuple 
access I[1], I[2],I[3])
Does calling bar(I) incur splatting overhead?
Is there overhead in the extra call, or will inlining remove the overhead?

- Greg