Home > utils > prob2str.m

prob2str

PURPOSE ^

[str] = prob2str(prob,crit,tok,places,return_ns)

SYNOPSIS ^

function [str] = prob2str(prob,crit,tok,places,return_ns)

DESCRIPTION ^

 [str] = prob2str(prob,crit,tok,places,return_ns)

 Converts probability value in prob to a sequence of tokens.

 crit - criterion probability above which to return 'n.s.'
 tok - token to use for string. Default: *
 places - number of places to go out to. Default: 1E-4 = ****

 E.g. 0.001 -> ***

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [str] = prob2str(prob,crit,tok,places,return_ns)
0002 % [str] = prob2str(prob,crit,tok,places,return_ns)
0003 %
0004 % Converts probability value in prob to a sequence of tokens.
0005 %
0006 % crit - criterion probability above which to return 'n.s.'
0007 % tok - token to use for string. Default: *
0008 % places - number of places to go out to. Default: 1E-4 = ****
0009 %
0010 % E.g. 0.001 -> ***
0011 %
0012 
0013 % 03/05/05/ PJ
0014 % 12Aug2014 PJ - added option to return empty string if n.s.
0015 if nargin < 5
0016   return_ns = 1;
0017 end
0018 
0019 if nargin < 4
0020   places = 4;
0021 end
0022 
0023 if nargin < 3
0024   tok = '*';
0025 end
0026 
0027 if prob < 10^-places
0028   str = repmat(tok,1,places);
0029 elseif prob <= crit
0030   str = repmat(tok,1,abs(fix(log10(prob))));
0031 else
0032   if return_ns
0033     str = 'n.s.';
0034   else
0035     str = '';
0036   end
0037 end

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003