[julia-users] Re: Broadcast slices

2016-09-25 Thread Steven G. Johnson
On Saturday, September 24, 2016 at 9:38:55 PM UTC-4, Brandon Taylor wrote: > > I guess, but I'm trying to write a generic program where I don't know the > size of the array? I'm trying to find Nash Equilibrium for an n dimensional > array, where the player strategies are along dimensions

[julia-users] Re: Broadcast slices

2016-09-25 Thread Davide Lasagna
Hi Brandon, you might find some inspiration from this package . Davide On Sunday, September 25, 2016 at 8:33:54 PM UTC+1, Dan wrote: > > Nice. > It is easier when the payoffs are in vector form. My last iteration: > > is_nash_equilibrium(po) = >

[julia-users] Re: Broadcast slices

2016-09-25 Thread Davide Lasagna
Hi Brandon, you might find some inspiration from this package . Davide On Sunday, September 25, 2016 at 8:33:54 PM UTC+1, Dan wrote: > > Nice. > It is easier when the payoffs are in vector form. My last iteration: > > is_nash_equilibrium(po) = >

[julia-users] Re: Broadcast slices

2016-09-25 Thread Dan
Nice. It is easier when the payoffs are in vector form. My last iteration: is_nash_equilibrium(po) = !reduce(|,falses(po[1]),(broadcast(<,po[i],mapslices(maximum,po[i],i)) for i=1:length(po))) A one-liner :) On Sunday, September 25, 2016 at 2:25:45 PM UTC-4, Brandon Taylor wrote: > > Cool!

[julia-users] Re: Broadcast slices

2016-09-25 Thread Brandon Taylor
Cool! The implementation I have is: equals_max(x) = x .== maximum(x) best_response_dimension(payoff_matrix, dimension) = mapslices(equals_max, payoff_matrix, dimension) is_nash_equilibrium(payoffs) = @chain begin payoffs broadcast(best_response_dimension, _, 1:length(_) )

[julia-users] Re: Broadcast slices

2016-09-25 Thread Dan
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: > >

[julia-users] Re: Broadcast slices

2016-09-25 Thread Dan
OK. So, to get the array to have the first dim as the player selector, you can go: cat(1,map(x->reshape(1,size(x)),array_of_arrays) Anyway, keeping with the same payoff_matrix as before, I realized you might just want a boolean array which is true if entry is a best response (for the

[julia-users] Re: Broadcast slices

2016-09-25 Thread Brandon Taylor
For now, I have an array of arrays. 1 payoff array for each player. The arrays can be zipped to get the strategy profiles. It seems to work, but having everything in 1 array just seems so much more neat. Which is why I was looking for a neat implementation of broadcast_slices to match. On

[julia-users] Re: Broadcast slices

2016-09-25 Thread Dan
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

[julia-users] Re: Broadcast slices

2016-09-24 Thread Brandon Taylor
Or I guess that should be broadcast_slices(best_response_dimension, player_dimension, payoff_matrix, players) On Saturday, September 24, 2016 at 9:38:55 PM UTC-4, Brandon Taylor wrote: > > I guess, but I'm trying to write a generic program where I don't know the > size of the array? I'm trying

[julia-users] Re: Broadcast slices

2016-09-24 Thread Brandon Taylor
I guess, but I'm trying to write a generic program where I don't know the size of the array? I'm trying to find Nash Equilibrium for an n dimensional array, where the player strategies are along dimensions 1:n-1, and the players are along dimension n. So: equals_max(x) = x .== maximum(x)

[julia-users] Re: Broadcast slices

2016-09-22 Thread Steven G. Johnson
At some point, it is simpler to just write loops than to try and express a complicated operation in terms of higher-order functions like broadcast.