Be the first to rate this file! 11 Downloads (last 30 days) File Size: 2.22 KB File ID: #3205

swap.m

by Brice Semmens

 

28 Mar 2003 (Updated 01 Apr 2003)

Randomly shuffles a binary matrix while keeping row and column sums the same as the original matrix.

| Watch this File

File Information
Description

This function carries out a swap algorithm as described in Stone and Roberts (1990), Oecologia 85:74-79. The data matrix must be organized with sites (islands) as rows, and species as columns. The function only works with binary matrices (but can be easily modified to convert abundance matrices).

"Swapping" randomly shuffles a binary matrix while keeping the row and column sums the same.

To call the function, send the data matrix and the number of swaps you wish to have carried out: swap(matrix,1000). The function returns the shuffled matrix. For each swap, the function randomly identifies two rows and columns such that:

[...0...1..;
..........;
...1...0..]

and then switches (swaps) the 0's and 1's within the columns.

Written by Brice X. Semmens (semmens@u.washington.edu), 03/26/03
Comments and modifications/improvements welcome.

MATLAB release MATLAB 5.3.1 (R11.1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
statistics Brice Semmens 22 Oct 2008 06:59:02
probability Brice Semmens 22 Oct 2008 06:59:02
null model Brice Semmens 22 Oct 2008 06:59:02
sequential swap Brice Semmens 22 Oct 2008 06:59:02
independent swap Brice Semmens 22 Oct 2008 06:59:02
swap Brice Semmens 22 Oct 2008 06:59:02
shuffle Brice Semmens 22 Oct 2008 06:59:02

Contact us at files@mathworks.com