?? probmut.m
字號:
function pmut = probmut(chr,muteinfo)% PROBMUT - Calculates the probability of mutation in the population.%% pmut=probmut(chr,muteinfo) returns the probability of mutation,% given the population (chr) and the mutation information (muteinfo).% The argument muteinfo is a structure containing user supplied% information, it is most easily constructed with ui_mutate.% Every species is assigned a probability of mutation and% transmutation. Currently a constant is used for transmutaion.% For mutation within a species a constant can be choosen, or the% probability of mutation is calculated using the diversity of% the subpopulation. %% See also UI_MUTATE, MUTATE, CHILDRENlen_pop=length(chr);for k=1:length(muteinfo); mut_lim=muteinfo(k).mut_lim; if isempty(mut_lim) pm=muteinfo(k).pc; else p_min=muteinfo(k).mut_lim(1); p_max=muteinfo(k).mut_lim(2); population=create_pop(chr,muteinfo(k).name); kk=-1*log(p_min/p_max); d=diverse(population); if d>1 d=1; end if d<0 d=0; end pm=p_max*exp(-1*kk*d); end muteinfo(k).pc=pm; pmut(k)=muteinfo(k); if isempty(pmut(k).trans) pmut(k).trans=[]; else pmut(k).trans=nmbr_of_members(chr,muteinfo(k).name)/len_pop; endend function pop = create_pop(chr,name)% CREATE_POP - Creates an old fashioned population% ind=find(chr,name);c=chr(ind);for k=1:length(c); cdvs=get(c(k),'cdvs'); ddvs=get(c(k),'ddvs'); if ~isempty(cdvs) tmp=[]; for l=1:length(cdvs); tmp=[tmp get(cdvs(l),'dna')]; end end if ~isempty(ddvs) for l=1:length(cdvs); tmp=[tmp get(ddvs(l),'dna')]; end end dn(k,:)=tmp;endpop=dn;function [d]=diverse(population)%% Type d=diverse(population)%%% This function calculates the diversity of the population,% using a "entropy like" measure.%% Copyright (c) 1994-1995 by David C. Zimmerman. All rights reserved[m,n]=size(population);p_one=sum(population)/m;p_zero=1-p_one;p_one=p_one.*log(p_one+ (1e-10));p_zero=p_zero.*log(p_zero+(1e-10));d=-1*(sum(p_one) + sum(p_zero))/(n*log(2));
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -