%This program generates fake data for testing the MixSIR program. %Written by BX Semmens on 6/30/07 %HOW IT WORKS... %set isotopes to 2 (this can be easily changed) %randomly draw the number of sources (2 - 10) %generate iso sig values for each source (randomize, but constrain to high and low vals for C and N) %generate SD in sources (randomize, but constrain to high and low values C and N) %do a random draw to get % contribs for each source %from that, define the pred iso signature with variance %DATA: %mean and variance of sources %mean and variance of pred %CREDIBLE INTERVALS FOR TWO ISOTOPES %CARBON : -35 to -15, SD between 1 and 2 %NITROGEN: 0 to 15, SD between 1 and 2 %CAVIATES % 1) these simulations are based on the mixture exclusively derived from % this sources... this assumption is always made in mixing models, but rarely true in % reality. %-------------------------------------------------------------------------- clear all; Cmax=-15;Cmin=-30;CmaxSD=2;CminSD=1; Nmax=15;Nmin=0;NmaxSD=2;NminSD=1; %set max number of sources mxsrc = 5; %specify the amount of data you want data_size=50; %number of sources src_num = round(rand * (mxsrc-2) + 2); %sets min to two sources, max to mxsrc %now randomly (uniform over interval) draw iso signatures for each source for i = 1:src_num src_C(i) = rand * (Cmax-Cmin) + Cmin; src_Csd(i) = rand * (CmaxSD-CminSD) + CminSD; src_N(i) = rand * (Nmax-Nmin) + Nmin; src_Nsd(i) = rand * (NmaxSD-NminSD) + NminSD; end %randomly generate the contribs from each source contribs = rand_props(src_num); %now iterate to generate fake mix data mix = zeros(data_size,2); random = randn(data_size,2); for i=1:data_size for j=1:src_num mix(i,1)= mix(i,1) + (contribs(j) * (src_C(j)+src_Csd(j).*random(i,1))); mix(i,2)= mix(i,2)+ (contribs(j) * (src_N(j)+src_Nsd(j).*random(i,2))); end end %now write the data files for MixSIR frac = zeros(src_num,2); %zeros out fractionation dlmwrite('mean_frac.txt',frac,'\t') dlmwrite('SD_frac.txt',frac,'\t') dlmwrite('mix_data.txt',mix,'\t') %dlmwrite('mean_pred.txt',mean(mix),'\t') %dlmwrite('SD_pred.txt',std(mix),'\t') dlmwrite('mean_source.txt',cat(2,src_C',src_N'),'\t') dlmwrite('SD_source.txt',cat(2,src_Csd',src_Nsd'),'\t')