Rank: 4 based on 8022 downloads (last 30 days) and 58 files submitted
photo

Jos

E-mail

Personal Profile:

Professional Interests:
neuroscience, physics, mathematics

 

Watch this Author's files

 

Files Posted by Jos View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
15 May 2009 Sylvester Matrix (v1.0, may 2009) SYLVESTER - Sylvester matrix of two polynomials Author: Jos determinant, polynomials, matrix, polynomial, this is not working s..., resultant 160 0
23 Apr 2009 GetKeyWait Wait a certain time for a single keypress (v2.0, apr 2009). Author: Jos pause, timed, input, kbhit, getkey, keypress 168 7
  • 4.83333
4.8 | 6 ratings
23 Apr 2009 getkey Get a single keypress (v1.2 apr 2009) Author: Jos kbhit, input, key, getch, getchar, hit 227 10
  • 4.5
4.5 | 6 ratings
06 Apr 2009 UNIQUEWITHEQUALNANS Set unique, treating NaNs as equal (v2.0, mar 2009) Author: Jos equal, isequal, compare, unique, matrices, utility 105 2
  • 4.0
4.0 | 1 rating
26 Mar 2009 BALLATSQ Create a balanced latin square (v2.2, mar 2009) Author: Jos matrix, statistics, special, probability, balanced latin, experiment 106 3
  • 5.0
5.0 | 1 rating
Comments and Ratings by Jos View all
Updated File Comments Rating
19 Nov 2009 Truth Table Generation This function simply computes the truth table for a given number of variables. Author: Mahendra

The pre-allocation and the use of logicals is certainly an improvement. Next try to improve the help section. See any standard function for inspiration how to set up such a comment section, for instance, DISP or MEAN. Also take a look at LOOKFOR to learn about H1 lines.

16 Nov 2009 Truth Table Generation This function simply computes the truth table for a given number of variables. Author: Mahendra

This submission has several problems.
1. The help section is insufficient: add a H1 line, a clear description how to use this function and what to expect, and add an example.

2. The for-loop is not pre-allocated, and therefore quite slow with large n

3. There are several faster alternatives, for instance
n = 4 ;
R = rem(floor([0:((2^n)-1)].'* pow2(0:-1:-n+1)),2)
(adapted from DEC2BIN)

05 Nov 2009 Level crossings Detect level crossing of signals. Author: roberto madia

Just curious what you mean by "This algorithm is generally faster than traditional ones". What are the traditonal ones?

I would suspect that an operation using something using DIFF and SIGN, as in (not-tested) "sum(diff(sign(Signal-OneLevel))) ~= 0)" is faster (as well as shorter)

05 Nov 2009 Allstats Many statistics of a vector Author: Francisco de Castro

It is nice to see some improvments Franciso! A couple of additional comments: if your sor worried about speed, I suggest you take a look at logical indexing, and replace all the zeros from the struct command by one call to zeros.

Another point: the behavior for 2D matrices should be explained, especially when the groups are specified. I think you did not intend that behavior. For instance, take a look if the following produces what you want them to produce:

A = rand(3,4) ; allstats(A), allstats(A,1:4), allstats(A,1:3)

With respect to the help, you can add examples of the expected output, besides giving only the calling syntax.

Below is the outline of a more optimized code:
function R = allstats(DATA, GROUP)
if isempty(ver('stats'))
    error('Function requires STATS toolbox.') ;
end
if nargin==1,
    GROUP = ones(numel(DATA),1) ;
    Ngroups = 1 ;
    UniqueGroups = 1 ;
else
    if numel(DATA) ~= numel(GROUP)
        error('Number of elements should match') ;
    end
    UniqueGroups = unique(GROUP) ;
    Ngroups = numel(UniqueGroups) ;
end
Z = nan(Ngroups,1) ;
R = struct('min',Z,'max',Z,'mean',Z) ; % etce
for k=1:Ngroups,
    Q = GROUP == UniqueGroups(k) ; % logical indexing
    R(k).min = nanmin(DATA(Q)) ;
    R(k).max = nanmax(DATA(Q)) ;
    R(k).mean = nanmean(DATA(Q)) ;
end

04 Nov 2009 Allstats Many statistics of a vector Author: Francisco de Castro

This submission can be improved considerably, considering the following:
1) when the data and group specification does not match, e.g., allstats([1 2 3],[1 2]), it should error
2) when the group data is not specified another piece of code is executed than when it is specified. Why not set the group data to all zeros, when no second argument is given. (and why not use nargin if the second argument is specified, instead of varargin)
3) Grouping does not work flawlessly: for instance ALLSTATS(rand(1,5),1:5) returns overall statistics, rather than statistics for the five individual groups
4) As Duane already mentioned, there should be reference, and some See Also's to the Stats TB and other functions

So, a lot to improve on this potential useful pick-of-the-week wrapper function.

Comments and Ratings on Jos' Files View all
Updated File Comment by Comments Rating
29 Oct 2009 GetKeyWait Wait a certain time for a single keypress (v2.0, apr 2009). Author: Jos Hopkins, Jesse

Just what I was looking for

15 Sep 2009 GetKeyWait Wait a certain time for a single keypress (v2.0, apr 2009). Author: Jos Negahbani, Ehsan

Great. Thank you Jos.
Is it possible to prevent the appearance of figure tab in the task bar?
I'm calling your function in a loop every second, and it works well, but there is continuous blinking between command window and windows task bar as your code opens and closes a figure window each time. I tried to off the 'visible' property of the figure, but it was not working...

11 Sep 2009 RANDP Random integers with given probabilities ( (v2.0) Author: Jos Pozzi, Francesco

I've tried this small experiment:

N = 100000; % sample size
w = 1:100; % quite steep distribution
w = w / sum(w); % distribution (pdf)
Y_std = sqrt(w .* (1 - w)); % Standard deviations associated to each probability

%%%%%%%%%%%%%%%%%

Y1 = randp(w, N, 1); % Try Jos function
Y1_w = histc(Y1, [1:100]); % absolute frequencies table
Y1_w = Y1_w / N; % transform into relative frequencies
Y1_w_std = sqrt(Y1_w .* (1 - Y1_w)); % Empirical standard deviations associated to each probability

%%%%%%%%%%%%%%%%%

Y2 = gDiscrPdfRnd(w, N, 1); % Try Gianluca Dorini's function
Y2_w = histc(Y2, [1:100]); % absolute frequencies table
Y2_w = Y2_w / N; % transform into relative frequencies
Y2_w_std = sqrt(Y2_w .* (1 - Y2_w)); % Empirical standard deviations associated to each probability

%%%%%%%%%%%%%%%%%

% Check if empirical standard deviations are coherent with theretical ones
plot(Y_std - Y1_w_std', '.b') % plot empirical differences for Jos function
hold on
plot(Y_std - Y2_w_std', '.r') % plot empirical differences for Gianluca Dorini's function

%%%%%%%%%%%%%%%%%

It looks as though both functions statistically behave very well. They are both excellent functions. Thank you.

04 Sep 2009 MATCHROW (v1.1, may 2008) Match elements in the rows of a matrix Author: Jos Romero, Mauricio

04 Sep 2009 RANDP Random integers with given probabilities ( (v2.0) Author: Jos Pozzi, Francesco

Wow, it really is a nice function, very fast and efficient. It is exactly what I was looking for. Thank you.

Top Tags Applied by Jos
matrices, matrix, probability, select, sort
Files Tagged by Jos View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
11 Aug 2009 Min/Max selection Search for k smallest or largest elements in the array Author: Bruno Luong max, min, quicksort, kthvalue, selection, partial sort 182 3
  • 5.0
5.0 | 1 rating
15 May 2009 Sylvester Matrix (v1.0, may 2009) SYLVESTER - Sylvester matrix of two polynomials Author: Jos determinant, polynomials, matrix, polynomial, this is not working s..., resultant 160 0
23 Apr 2009 GetKeyWait Wait a certain time for a single keypress (v2.0, apr 2009). Author: Jos pause, timed, input, kbhit, getkey, keypress 168 7
  • 4.83333
4.8 | 6 ratings
23 Apr 2009 getkey Get a single keypress (v1.2 apr 2009) Author: Jos kbhit, input, key, getch, getchar, hit 227 10
  • 4.5
4.5 | 6 ratings
06 Apr 2009 UNIQUEWITHEQUALNANS Set unique, treating NaNs as equal (v2.0, mar 2009) Author: Jos equal, isequal, compare, unique, matrices, utility 105 2
  • 4.0
4.0 | 1 rating
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com