Have you found the right implementation?
Fiddling a bit, I tend to agree with Steven G. Johnson `for` loops would be
the most efficient and probably the most understandable implementation.
Also, would it not be easier to have the first index in the `payoff_matrix`
determine which player's payof
1 array just seems so much more neat. Which is why I
> was looking for a neat implementation of broadcast_slices to match.
>
> On Sunday, September 25, 2016 at 10:53:57 AM UTC-4, Dan wrote:
>>
>> Have you found the right implementation?
>>
>> Fiddling a bit, I ten
Oops, that `cat` code was supposed to be:
cat(1,map(x->reshape(x,1,size(x)...),array_of_array)...)
Mew!
On Sunday, September 25, 2016 at 11:54:43 AM UTC-4, Dan wrote:
>
> OK. So, to get the array to have the first dim as the player selector, you
> can go:
>
> cat(1,map(x
best_response_dimension, _, 1:length(_) )
> zip(_...)
> map(all, _)
> end
>
> On Sunday, September 25, 2016 at 11:57:47 AM UTC-4, Dan wrote:
>>
>> Oops, that `cat` code was supposed to be:
>>
>> cat(1,map(x->reshape(x,1,size(x)...),array_of_array)...)
That last line was probably meant to be
paths = Vector{Matrix{Float64}}(4)
On Tuesday, September 27, 2016 at 7:01:14 PM UTC-4, Yichao Yu wrote:
>
> On Tue, Sep 27, 2016 at 6:28 PM, Zhilong Liu > wrote:
> > Hello All,
> >
> > I am trying to return values to elements inside a structure-like mat
If saving characters is a thing, then:
julia> a = rand(Bool,3,2)
3×2 Array{Bool,2}:
false false
true false
false true
julia> 1a
3×2 Array{Int64,2}:
0 0
1 0
0 1
On Monday, October 17, 2016 at 2:08:44 PM UTC+3, Scott Jones wrote:
>
> Tim, do you know if there is any difference in p
h is not too hard as well.
G'day, Dan Getz
On Friday, October 21, 2016 at 3:43:05 AM UTC+3, Joaquim Masset Lacombe
Dias Garcia wrote:
>
> Hi,
>
> Have anybody implemented an arbitrary jump ahead for Mersenne Twister in
> julia?
>
> I saw that the randjump do
a = Vector{String}
is also a good option.
On Monday, November 7, 2016 at 5:27:49 PM UTC+2, Steven G. Johnson wrote:
>
>
>
> On Monday, November 7, 2016 at 9:45:37 AM UTC-5, Mauro wrote:
>>
>> On Mon, 2016-11-07 at 15:27, Fred wrote:
>> > Hi Steven,
>> >
>> >
>> > I also tried a = Array{Str
I meant,
a = Vector{String}()
Dan
On Tuesday, November 8, 2016 at 9:39:53 AM UTC+2, Dan wrote:
>
> a = Vector{String}
>
>
>
> is also a good option.
>
> On Monday, November 7, 2016 at 5:27:49 PM UTC+2, Steven G. Johnson wrote:
>>
>>
>>
>> On Mon
F(a,b) = floor(Int,a/b)*b
seems to fit the examples.
On Thursday, October 8, 2015 at 6:01:07 PM UTC+3, Sisyphuss wrote:
>
> Hello everyone,
>
> I want a function F(), so that
> F(0.154, 0.1) = 0.1
> F(0.154, 0.01) = 0.15
> F(0.154, 0.003) = 0.153
>
> I tried `div(a,b)*b`. However, I got:
>
> d
Since this is a common procedure when counting items in sequences, there is
a specialized function (`merge`) and data structure (`Accumulator`) for it
in the package `DataStructures`. Try a version of the following:
using DataStructures
a = Dict(2 => 5, 3 => 7, 5 => 1)
b = Dict(2 =
perhaps,
fill!(instance.ol, Tuple{Int64, Array{Float64}}[])
uses the same address to fill every entry in `instance.ol` and the behavior
observed follows. maybe,
onstance.ol = [Tuple{Int64,Array{Float64}}[] for
i=1:length(instance.ol)]
would be better.
On Tuesday, October 13, 2015 at 7:52
Recently, Peter Norvig published a lovely IPython/Jupyter notebook on
probability and related puzzles. Mostly as an exercise, I've done a translation
to Julia. It was educational to me, and getting stuff translated into Julia is
the best way to make sure Julia doesn't overlook important function
yeah. it wasn't optimized for efficiency but rather for closeness to original
python code. the python version used generators and hence Julia tasks. same
goes for the coin flipping.
This might have something to do with matching parameter T correctly. T
could actually be an Array type and then Array{T,1} would be an Array of
Arrays. This is creates ambiguity.
In any case, a solution might be to define:
dispatchtest{T}(x0::Array{T,1},x::Vararg{Union{T,Array{T,1}}}) = "success
the inner constructor, can separate allocation and initialization of a new
object. specifically, first do a:
newobj = new()
then you can set the fields. with a loop this can look like:
fieldvalues = Any[val1,val2,val3]
On Thursday, October 22, 2015 at 4:14:51 PM UTC+3, Sloan Lindsey wrote:
Oops, random click on post.
So:
function MyType(..)
:
:
fieldvalues = Any[val1,val2,val3]
fnames = fieldnames(MyType)
for i=1:length(fnames)
setfield!(newobj,fname[i],fieldvalues[i])
end
return newobj
end
On Thursday, October 22, 2015 at 5:52:34 PM UTC+3, Dan wrote:
>
> the
copy-pasted the above and noticed:
a) works nicely!
b) needs a `using Dates` or `Dates.unix2datetime` to work on my 0.4 release.
c) `t -> last(t)` could be just `last`
On Saturday, October 24, 2015 at 11:43:28 AM UTC+3, cormu...@mac.com wrote:
>
> Perhaps
>
> first(sort(map(f -> (realpath(f),
putting the transpose inside, might look nicer to some:
esol = vcat([exact(t)' for t in linspace(0, 10, 100)]...)
On Tuesday, October 27, 2015 at 6:52:21 PM UTC+2, Gabriel Gellner wrote:
>
> Sadly that wants to make a matrix of two long rows ;) like the hcat(...).
> So needs the transpose as
If you do a:
precomp = map(log10,2:10)
Then a oneliner for the first digit is:
searchsortedfirst(precomp, log10(lista[3])%1.0)
There are many paths in the garden. But this one is not as long (slow) as
it looks.
On Tuesday, October 27, 2015 at 10:35:18 AM UTC+2, Alireza Nejati wrote:
perhaps the [count*] notation means: repeat the line count times i.e.:
hd1
hd1
hd2
hd2
:
no time to dig or test yet, so this is just another guess.
On Wednesday, October 28, 2015 at 9:36:08 PM UTC+2, Ismael VC wrote:
>
> Hello everyone,
>
> I have succesfully added all nodes and I can init julia
XXX in your questions = chain.
Or more clearly:
julia> stream = chain([1,2,3,4,5])
Iterators.Chain(Any[[1,2,3,4,5]])
julia> collect(take(stream, 3))
3-element Array{Any,1}:
1
2
3
On Monday, November 9, 2015 at 7:47:51 PM UTC+2, andrew cooke wrote:
>
>
> hmmm. maybe i'm doing it wrong as that
bered somewhere.
On Monday, November 9, 2015 at 10:07:52 PM UTC+2, Dan wrote:
>
> XXX in your questions = chain.
> Or more clearly:
> julia> stream = chain([1,2,3,4,5])
> Iterators.Chain(Any[[1,2,3,4,5]])
>
> julia> collect(take(stream, 3))
> 3-element Array{Any,1}:
>
/JuliaLang/Iterators.jl i guess.
>
> it doesn't support read though (which i didn't realise i needed when i
> first asked).
>
> i'll add a warning to StatefulIterators pointing people to this.
>
> thanks,
> andrew
>
> On Monday, 9 November 2015 17:07:52
2
3
julia> collect(rest(1:3,start(1:3)))
3-element Array{Any,1}:
1
2
3
Shouldn't the type of both arrays be the same? (the latter defined in
non-global context still yield Any Array).
On Monday, November 9, 2015 at 10:45:12 PM UTC+2, Dan wrote:
>
> the example with `pull` befor
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, Nov
`x .> 3` is a bit-array. The function form, which is probably what fits, is
`x->x.>3` (the back-ticks are for quotation, not part of the code).
AFAIK the implementation of `push!` in Julia only occasionally allocates a
bigger buffer for the new vector. This results in a very low average time
for adding multiple elements (O(1) amortized time in complexity jargon).
Notice, `a = [a new_element ]` would in Julia do something else than
`pus
the columns of A'A when A is sparse are just sparse linear combinations of
columns of A. the coefficients being stored in the column-based sparse
matrix representation (internally a vector of coefficients with pointers to
new-column indices). so simply generating column by column with a for loop
`convert` is the go-to equivalent in Julia of casting. In this case:
uint_array = convert(Vector{UInt8},str)
but there are many ways of getting similar results!
BTW `convert(ASCIIString,uint_array)` gets back.
On Wednesday, November 18, 2015 at 1:49:36 AM UTC+2, James Gilbert wrote:
>
> Solv
Well, its not as simple as that because of everything being sparse (adding
columns is not just a loop over sum). Actually, it would be interesting to
see a clever solution.
On Wednesday, November 18, 2015 at 2:14:39 AM UTC+2, Dan wrote:
>
> the columns of A'A when A is sparse are
On Wednesday, November 18, 2015 at 2:30:14 AM UTC+2, Dan wrote:
>
> Well, its not as simple as that because of everything being sparse (adding
> columns is not just a loop over sum). Actually, it would be interesting to
> see a clever solution.
>
> On Wednesday, November 18, 201
)
while sp.colptr[col+1]=sp.colptr[col2+1]
col2+= 1
end
@show col,col2,sp.nzval[i],sp.nzval[j]
res[col,col2] += sp.nzval[i]*sp.nzval[j]
end
end
res
end
On Wednesday, November 18, 2015 at 3:35:30 AM UTC+2, Dan wrote:
>
> T
]*sp.nzval[j]
end
end
res
end
On Wednesday, November 18, 2015 at 3:54:56 AM UTC+2, Dan wrote:
>
> Oops... a bug (which showed itself when matrix was sparser than my
> previous tests):
> [when columns where completely empty, the first `if` should have been a
> `while
It works, but it is slow (compared to `full(A'*A)`)
On Wednesday, November 18, 2015 at 3:56:31 AM UTC+2, Dan wrote:
>
> And finally, getting rid of debug print.
>
> function AtrA(sp::SparseMatrixCSC)
> res = zeros(eltype(sp),sp.n,sp.n)
> col = 1
> @inboun
Embarrassingly, there is yet another bug.
while sp.colptr[col+1]=sp.colptr[col2+1]
col2+= 1
end
res[col,col2] += sp.nzval[i]*sp.nzval[j]
end
end
res
end
On Wednesday, November 18, 2015 at 4:18:37 AM UTC+2, Dan wrote:
>
> It works, but
so get improvement for the original problem.
The trick is doing the calculation in the right direction for the sparse
storage, and it also uses the fact A multiplied by its own transpose. The
exact speedup depends on the density and size. But I got 4x on
`sprand(200,400,0.1)`
On Wednesday, Novembe
How about this:
using StatsBase
using Iterators
function uniquepermutations(base)
zpos = Vector{Vector{Vector{Int}}}()
zval = Vector{Int}()
left = length(base)
for (v,c) in countmap(base)
push!(zpos,collect(subsets(collect(1:left),c)))
push!(zval,v)
left -=
Well, the previous listing worked only for Int vectors. Following is a more
properly typed version.
Various optimizations are possible: @inbounds, reducing allocations, etc.
function uniquepermutations(base)
zpos = Vector{Vector{Vector{Int}}}()
zval = Vector{eltype(base)}()
left = le
Knuth's lexicographic permutations version is best (in terms of speed, memory.
perhaps less readable).
The function name in the code snippet even has a little permutation by itself ;)
Regarding the last printing point only
print(string(eltype(8)) * ", " * string(eltype(8)))
is probably what you meant. AbstractString(Int64), tries to create an
AbstractString from an Int64, while string(Int64) asks for a string
representation. The latter semantics is more accurate, and works.
Hi Arin,
It would be helpful to have more details about the input (a dataframe?) and
output (a two-by-two table or a table indexed by categories?). Some code to
give context to the question would be even more help (possibly in another
language, such as R).
Having said this, here is a starting p
`split` already has hooks for using other splitters. To achieve the UTF8
space splitting functionality, one can leverage the `isspace` function and
add some decorations. For example:
type FuncSplitter
pred::Function
end
function Base.search(s::AbstractString, splt::FuncSplitter, start::In
If we are already at this, it would be cool to have versions with Gray ordering.
Something like:
for (i1,i2) in permutations(vector,indices=true,Gray=true)
theperm[[i1,i2]] = theperm[[i2,i1]]
@show theperm
end
would go over all permutations.
The syntax would be different and t
Using `append!` instead of `push!` and letting efficient dynamic
reallocation of vector do the resizing:
function vcat_nosplat2a(y)
result = Array(eltype(y[1]), 0)
for a in y
append!(result, a)
end
result
end
(@benchmark shows way less allocations and 2-3x time)
BTW the s
I've managed to reproduce the timing peculiarities you described, with a
different function. In fact, I get the same first run slower behavior even
with regular functions with -no- keywords. It is almost as if `precompile`
is not doing the entire job.
Have you tried, just testing the basic preco
Aha! tested the same sequence in a non-REPL run and the 1st and 2nd
runtimes after a `precompile` are the same.
On Wednesday, November 25, 2015 at 10:23:04 PM UTC+2, Dan wrote:
>
> I've managed to reproduce the timing peculiarities you described, with a
> different function. In f
rapper)
{
:
:
:
if (sf->linfo->functionObject != NULL) {
// found in the system image: force a recompile
Function *llvmf = (Function*)sf->linfo->functionObject;
if (llvmf->isDeclaration()) {
sf->linfo->specFunctionObject = NULL;
sf->li
have you tried running collect within a function? sometimes the Global
scope is bad for type inference.
On Saturday, November 28, 2015 at 2:45:26 AM UTC+2, ele...@gmail.com wrote:
>
> Collect only requires that the collection is iterable, for which providing
> an eltype() function is optional.
Looking at the collect code, it seems you really should define Base.eltype for
your iterator and things will work out.
On Saturday, November 28, 2015 at 3:15:18 AM UTC+2, Seth wrote:
>
> I guess that makes sense, though I struggle to see why one would create an
> iterator that produces multiple
Since this situation comes up once in a while, it might be nice to have a
copyfill which does a copy on each cell. In code:
function copyfill!{T}(a::Array{T}, x)
xT = convert(T, x)
for i in eachindex(a)
@inbounds a[i] = copy(xT)
end
return a
end
copyfill(v, dims::Dims)
`. all this is unnecessary, but might
help for readability purposes.
On Sunday, November 29, 2015 at 3:49:19 PM UTC+2, Milan Bouchet-Valat wrote:
>
> Le dimanche 29 novembre 2015 à 04:21 -0800, Dan a écrit :
> > Since this situation comes up once in a while, it might be nice to
> &g
Can you provide the comparable python code? Perhaps even the data used for
testing?
Since you are evaluating Julia, there are two important points to remember:
1) In Julia because the language is fast enough to implement basic
functionality in Julia, then the distinction between Base Julia and
Some points:
1) If you are timing the program by running from shell (i.e. including the
whole Julia load time) - it's not a good idea for a bunch of reasons.
2) The printouts are also a little dubious to be used in a test.
3) Too short an input makes the test noisy.
On Monday, November 30, 2015
:
for t in sort(collect(wc), lt=customlt)
println(t.first, "\t", t.second)
end
end
On Monday, November 30, 2015 at 5:08:56 PM UTC+2, Dan wrote:
>
> Can you provide the comparable python code? Perhaps even the data used for
> testing?
>
> Since you are eval
om/juditacs/wordcount#leaderboard for details)
>
> Dan:
> I can use external packages, it's not a big issue. However, FastAnonymous
> didn't give results comparable to python.
> The baseline python code I compare to is here:
> https://github.com/juditacs/wordcoun
and replacing
println("$(t.first)\t$(t.second)")
with
@printf("%s\t%d\n",t.first,t.second)
also halves the print time (which might or might not make a big difference
but definitely > 1 second)
On Monday, November 30, 2015 at 6:20:54 PM UTC+2, Dan wrote:
suggestion: call the named argument `lt` to match the argument of `sort`.
On Tuesday, December 1, 2015 at 6:23:07 PM UTC+2, Júlio Hoffimann wrote:
>
> Hi Erik,
>
> What I meant was a derived type from Julia's Tuple type. Though I agree
> with you that this may be too much of an overhead for such
The shift and AND operators are usually used in these situations (>> and
&). With the following definition:
getbit(x::UInt64,i) = Int((x >> (64-i))&1)
You can get any bit from a 64-bit unsigned integer. For example
getbit(0xa7f1d92a82c8d8fe,29).
On Wednesday, December 2, 2015 at 11:41:51 AM UT
*A non-breaking Julia control-flow change to separate the One language from
mortal languages, doomed to die
*
>From a design patterns and DRY perspective it seems `for` loops together with
>the `break` statement are serving
as a useful `try`/`catch` mechanism for non-error situations. A common
*A non-breaking Julia control-flow change to separate the One language from *
*mortal languages, doomed to die
*
>From a design patterns and DRY perspective it seems `for` loops together with
>the `break` statement
are serving as a useful `try`/`catch` mechanism for non-error situations. A
c
*A non-breaking Julia control-flow change to separate the One language from *
*mortal languages, doomed to die
*
>From a design patterns and DRY perspective it seems `for` loops together with
>the `break` statement
are serving as a useful `try`/`catch` mechanism for non-error situations. A
c
27;m sure the syntax needs cleaning up.
>
> -erik
>
>
>
> On Wed, Dec 9, 2015 at 10:47 AM, Seth > wrote:
>
>> Seems to me that this is just a more complex repeat...until or do...while
>> bottom-conditional loop, which has already been discussed and rejected (
the following re-reads the header and generates a dictionary which assigns
the original column name to the converted one, in a one-liner-ish:
df = readtable("/the/file.csv")
h = Dict(zip(keys(df.colindex.lookup),split(open("/tmp/file.csv") do f
chomp(readline(f)) ; end,",")[collect(values(df.co
Linear algebra tells us Symmetric matrices have real eigenvalues and
general matrices have complex eigenvalues in general. `eigvecs` can be
called with an upper and lower bound on the eigenvalues of the eigenvectors
to be found, but upper and lower bounds are applicable only to Real
numbers, wh
The parameter for the `cvode` function is `f` and so is the function you
want to use. These get confused, and it tries to use the "function" `J`
instead. Changing the parameter name to something other than `{f}` should
work
On Wednesday, December 16, 2015 at 4:26:41 PM UTC+2, Simon Frost wrote:
Is the following red expression a good Julia equivalent:
julia> a = [ -1 2; 3 -4 ]
⋮
julia> y = [ 1, 2 ]
⋮
julia> [a[i,y[i]] for i=1:2]
2-element Array{Any,1}:
-1
-4
(it's also fast)
On Sunday, December 20, 2015 at 2:44:20 AM UTC+2, Lex wrote:
>
> I am expecting [-1 -4] in the Julia e
Hello All,
Given a vector (v) of length n, if I want to truncate it to its first k
elements. How does one do this?
My code currently uses `deleteat!(v,(k+1):length(v))`. But this is somewhat
cumbersome and might be inefficient since `deleteat!` has to take care of
all other ranges of elements
Great.
This is exactly what I needed.
On Thursday, June 9, 2016 at 5:11:05 PM UTC-4, Kristoffer Carlsson wrote:
>
> Use resize! maybe.
Not sure, but I may have had a similar problem and doing (in the shell):
git config --global url."https://".insteadOf git://
solved it.
On Sunday, June 12, 2016 at 1:42:13 PM UTC-4, Andreas Lobinger wrote:
>
> Hello colleagues,
>
> like with similar problems, i don't know how i ended up ther
A reason such 'extended' ranges might be good, is the ability to dispatch
on them for efficiency. For example, `deleteat!(vec,5:end)` could be
implemented faster than just any `deleteat!` of any range. This would be
applicable to other such structures with edge effects. Indeed, we can learn
fr
The print to screen statement is rather unequivocal. By elimination, the -1
in the file is the culprit. My guess is the -1 in the file is the value of
a different variable. When writing to the file, add some text to identify
which line is which var. Notice all vars are initialized to -1.
P.S. I
[[M] [M]] works.
And is the same as Matrix{Float64}[[M] [M]]
But concur it is unintuitive.
On Thursday, June 23, 2016 at 10:28:39 PM UTC-4, Sheehan Olver wrote:
>
>
> [M,M] will do a Vector of Matrices in 0.5. But [M M] still does
> concatenation. So the question is how to do Matrice
Yes, this is the intended functionality because # is used a character which
starts a comment in the file which is not parsed. The simplest way around
this is to disble comments using the named parameter `comments` like this:
readdlm(file,'\t',comments=false)
You can also change the character
Can you explain why it modified the one from the second block?
On Friday, July 1, 2016 at 9:58:26 AM UTC-4, FANG Colin wrote:
>
> Never mind, I get it.
>
> On the third run, the `state` variable that `counter` modified is the one
> from the second let block.
>
`readuntil` is your friend.
`readline` uses `readuntil`. In fact, it is defined as:
readuntil(s,'\n')
On Saturday, July 9, 2016 at 7:40:37 AM UTC-4, Fred wrote:
>
> Hi !
>
> It is often very useful to read a text files by blocks of lines, using
> another line separator than '\n'.
>
> Especial
Hi Gabe,
SuiteSparse which comes together with Julia includes a library KLU which
does sparse LU factorization. It has the option to return the fill-in
reducing order it manages to find for a given sparsity pattern. With this
returned structure it can subsequently factorize many matrices (and s
different solution it would be
interesting to hear about it.
On Sunday, July 10, 2016 at 9:38:44 PM UTC-4, Gabriel Goh wrote:
>
> I'd love more details Dan!
>
> On Saturday, July 9, 2016 at 8:53:16 PM UTC-7, Dan wrote:
>>
>> Hi Gabe,
>>
>> SuiteSparse whi
+1
There was also a suggestion at JuliaCon the badge could count the number of
warnings displayed - perhaps, this would give some incentive for
progressive cleanup/levelingup of code.
On Tuesday, July 12, 2016 at 1:15:24 PM UTC-4, Erik Schnetter wrote:
>
> Our Julia projects live on Github, and
and as it should be
A*x == v
is true.
Hope this helps.
-- Dan
On Friday, July 15, 2016 at 2:50:01 PM UTC-4, Kurolong wrote:
>
> Hey Guys and Gals ^^
> I'm having trouble with Julia. Maybe one of you can help me out
> The program i am writing requires the
> linear-equation-
The following standalone version recovers the speed of `test2` using the
@fastmath macro. Integer exponents have trade-offs in implementation using
repeated squaring and multiplication and intrinsic power instructions. Not
really sure how to control the implementation used in every instance.
fu
Try keeping the loop over all primes and breaking when `a > maxp` where
maxp is calculated once before the loop as `maxp = floor(Int,sqrt(n))`.
On Monday, August 22, 2016 at 4:58:30 PM UTC-4, Achu wrote:
>
> I have a simple piece of code that finds me 10001 prime numbers.
>
> function a()
> pl=[
Hi,
I am trying to create a Julia server instance by using ZMQ with the Req/Rep
pattern. My Julia code for the Rep-server looks like this:
module JServer
# import zmq
using ZMQ
import Base.gc
# create context
ctx=Context();
# create socket
socket=Socket(ctx, REP);
# msg
msg = 0;
# repeate
This did the trick. Thanks!
Maybe the following is the form you are looking for:
julia> decomplexify{T}(::Type{Complex{T}}) = T
decomplexify (generic function with 1 method)
julia> type bar{S,T}
sum::S
sumsqr::T
function bar(s,ss)
if typeof(ss) != decomplexify(typeof(s))
Thanks Kristoffer, turns out there is always interesting stuff in the bag
of optimization tricks.
Regarding the original function, a cheat could make it faster: The `x`
vector is sorted, which means:
function calcSum4(x::Array{Float64,1}, y::Array{Float64,1}, Ei::Float64,
Ef::Float64, N::Int64)
15 at 11:54:27 PM UTC+2, Charles Santana wrote:
>
> Thanks, Dan! Indeed my "x" vector is sorted and your suggestion is really
> fast!
>
> Best,
>
> Charles
>
> On 30 December 2015 at 12:08, Dan > wrote:
>
>> Thanks Kristoffer, turns out there is a
For the special problem of getting all the betas in the post, they can be
calculated with combinatorics:
betas(levels,parts) =
map(x->([x;levels+parts].-[0;x]-1)/parts, combinations(1:(levels+parts-1
),(levels-1)))
The idea is to choose which parts of (0.0,0.2), (0.2,0.4)... (0.8,1.0) go
in
Essentially, not much. `union` accepts multiple arguments with multiple
types, but `unique` accepts a single collection.
For example:
union(1,2,3,3) == unique([1,2,3,3])
This would probably make `union` slightly slower.
On Wednesday, January 13, 2016 at 11:58:18 PM UTC+2, Sheehan Olver wrote:
>
>
Another way to go about it, is to look at R's implementation of a random
permutation and recreate it in Julia, hoping for similar performance.
Having done so, the resulting Julia code is:
function nrandperm(r::AbstractRNG, n::Integer)
res = Array(typeof(n),n)
if n == 0
at 4:43:36 PM UTC+2, Kevin Squire wrote:
>
> Hi Dan,
>
> It would also be good if you deleted that post (or edited it and removed
> the code), for the same reason Viral mentioned: if someone reads the post
> and then creates a pull request for changing the Julia implementati
A good description of random permutation generation is given in Wikipedia.
It's the Fisher-Yates algorithm and its variants.
On Saturday, January 23, 2016 at 4:43:36 PM UTC+2, Kevin Squire wrote:
>
> Hi Dan,
>
> It would also be good if you deleted that post (or edited it a
>From the help for `cat`:
cat(dims, A...)
Concatenate the input arrays along the specified dimensions in the
iterable dims
And indeed, if
size(M1)=(3,3,3)
and
size(M2)=(3,3)
Then,
size(cat(3,M1,M2)) = (3,3,4)
This method may not be efficient (though in terms of memory layou
On Monday, February 22, 2016 at 12:18:02 PM UTC+2, Tamas Papp wrote:
>
>
> On Mon, Feb 22 2016, Aleksandr Mikheev wrote:
>
> > Hi everyone. I have two simple questions, answer to which I cannot find
> by
> > myself.
> >
> > 1. Is there any way to add an element to array? For example, I have
The matrix `D` is based on type `Int8` which overflows and wraps (without
error) very quickly. The `cov` function automatically converts to a `Float64`
but the manual calculation does not. To make the calculations match, try:
D = convert(Matrix{Int},D)
On Friday, March 4, 2016 at 10:42:02 AM UTC
trunc_to_inf and add an alias trunc_to_zero for regular trunc ??
On Saturday, March 12, 2016 at 1:49:41 PM UTC+2, Jeffrey Sarnoff wrote:
>
> x = trunc(fp) yields fp rounded towards zero to the closest integer valued
> float.
> What name would you give to the complementary function, rounding away
It's better to have code which actually runs in the post. In any case, the
allocations at the `for` lines is suspicious - the for should basically
only allocate a counter. Are there any global variables? Is `counter1` or
`counter2` or `dims` global? Globals are always a good source of confusion
unning the code from the REPL, may that be a problem? (As I read in
> the REPL everything is global). In the file nothing is global.
> Also, the counters are UInt16s, but that shouldnt matter I guess.
>
> Thanks for the help so far!
>
> On Saturday, 12 March 2016 14:22:38 UTC+1, Dan
# something along these lines:
topleft(A,d) = tuple(ones(Int,ndims(A))...)
bottomleft(A,d) = tuple([i==d ? 1 : e for (i,e) in enumerate(size(A))]...)
topright(A,d) = tuple([i==d ? e : 1 for (i,e) in enumerate(size(A))]...)
bottomright(A,d) = size(A)
mapedges(A,d) = zip(
CartesianRange{Cartesian
as a matrix
reshape(map(x->A3[x[1]]+A3[x[2]],mapedges(A3,3)),dropdim(A3,3))
On Thursday, March 24, 2016 at 3:21:02 AM UTC+2, Dan wrote:
>
> # something along these lines:
>
> topleft(A,d) = tuple(ones(Int,ndims(A))...)
> bottomleft(A,d) = tuple([i==d ? 1 : e for (i,e) i
1 - 100 of 154 matches
Mail list logo