From d837594e29d909baa53ab7253dd19fbc24e29dc6 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 20 Aug 2012 16:24:45 +0200 Subject: [PATCH] Add more images and improves the examples Change-Id: I8e08cf91d78d7efd5f18c3bff162688833636ec2 --- .../help/en_US/searchandsort/dsearch.xml | 70 ++++++++++++++++++-- .../graphics/help/en_US/2d_plot/histplot.xml | 25 +++++++ .../graphics/help/en_US/2d_plot/polarplot.xml | 45 +++++++++++-- .../graphics/help/en_US/geometric_shapes/xarc.xml | 28 +++++++- .../statistics/help/en_US/summaries/tabul.xml | 23 +++++-- 5 files changed, 174 insertions(+), 17 deletions(-) diff --git a/scilab/modules/elementary_functions/help/en_US/searchandsort/dsearch.xml b/scilab/modules/elementary_functions/help/en_US/searchandsort/dsearch.xml index 28fd211..85dd365 100644 --- a/scilab/modules/elementary_functions/help/en_US/searchandsort/dsearch.xml +++ b/scilab/modules/elementary_functions/help/en_US/searchandsort/dsearch.xml @@ -11,7 +11,7 @@ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt * --> - + dsearch @@ -345,8 +345,8 @@ dsearch : the array s (arg 2) is not well ordered this is the empirical histogram of the uniform distribution function. The expectation for occ/m is equal to 1/(n-1). - + + m = 50000 ; + n = 10; + X = grand(m,1,"def"); + s = linspace(0,1,n)'; + [ind, occ] = dsearch(X, s); + e = 1/(n-1)*ones(1,n-1); + scf() ; + plot(s(1:n-1), occ/m,"bo"); + plot(s(1:n-1), e,"r-"); + legend(["Experiment","Expectation"]); + xtitle("Uniform random numbers","X","P(X)"); + In the following example, we compare the histogram of binomially distributed random numbers with the binomial probability distribution function B(N,p), @@ -380,6 +393,21 @@ plot(s,Pexa',"r-"); xtitle("Binomial distribution B(8,0.5)","X","P(X)"); legend(["Experiment","Expectation"]); ]]> + + N = 8 ; + p = 0.5; + m = 50000; + X = grand(m,1,"bin",N,p); + s = (0:N)'; + [ind, occ] = dsearch(X, s, "d"); + Pexp = occ/m; + Pexa = binomial(p,N); + scf() ; + plot(s,Pexp,"bo"); + plot(s,Pexa',"r-"); + xtitle("Binomial distribution B(8,0.5)","X","P(X)"); + legend(["Experiment","Expectation"]); + In the following example, we use piecewise Hermite polynomials to interpolate a dataset. @@ -421,9 +449,43 @@ legend(["Experiment","Expectation"]); plot(x,y,"bo") xtitle("Hermite piecewise polynomial"); legend(["Polynomial","Data"]); - // NOTE : you can verify by adding these ones : + // NOTE : it can be verified by adding these ones : // YY = interp(X,x,y,d); plot2d(X,YY,3,"000") ]]> + + + function y=Ll(t,k,x) + y=(t-x(k+1))./(x(k)-x(k+1)) + endfunction + function y=Lr(t,k,x) + y=(t-x(k))./(x(k+1)-x(k)) + endfunction + function y=Hl(t,k,x) + y=(1-2*(t-x(k))./(x(k)-x(k+1))).*Ll(t,k,x).^2 + endfunction + function y=Hr(t,k,x) + y=(1-2*(t-x(k+1))./(x(k+1)-x(k))).*Lr(t,k,x).^2 + endfunction + function y=Kl(t,k,x) + y=(t-x(k)).*Ll(t,k,x).^2 + endfunction + function y=Kr(t,k,x) + y=(t-x(k+1)).*Lr(t,k,x).^2 + endfunction + + x = [0 ; 0.2 ; 0.35 ; 0.5 ; 0.65 ; 0.8 ; 1]; + y = [0 ; 0.1 ;-0.1 ; 0 ; 0.4 ;-0.1 ; 0]; + d = [1 ; 0 ; 0 ; 1 ; 0 ; 0 ; -1]; + X = linspace(0, 1, 200)'; + ind = dsearch(X, x); + + Y = y(ind).*Hl(X,ind) + y(ind+1).*Hr(X,ind) + d(ind).*Kl(X,ind) + d(ind+1).*Kr(X,ind); + scf(); + plot(X,Y,"k-"); + plot(x,y,"bo") + xtitle("Hermite piecewise polynomial"); + legend(["Polynomial","Data"]); + See Also diff --git a/scilab/modules/graphics/help/en_US/2d_plot/histplot.xml b/scilab/modules/graphics/help/en_US/2d_plot/histplot.xml index 3085021..3967157 100644 --- a/scilab/modules/graphics/help/en_US/2d_plot/histplot.xml +++ b/scilab/modules/graphics/help/en_US/2d_plot/histplot.xml @@ -110,6 +110,10 @@ clf();histplot(20,d,normalization=%f) clf();histplot(20,d,leg='rand(1,10000,''normal'')',style=5) clf();histplot(20,d,leg='rand(1,10000,''normal'')',style=16, rect=[-3,0,3,0.5]); ]]> + + d=rand(1,10000,'normal'); + clf();histplot(20,d,leg='rand(1,10000,''normal'')',style=16, rect=[-3,0,3,0.5]); + Example #2: histogram of a binomial (B(6,0.5)) random sample @@ -124,6 +128,17 @@ subplot(2,1,2) histplot(c, d, normalization=%f, style=5) xtitle("non normalized histogram") ]]> + + d = grand(1000,1,"bin", 6, 0.5); + c = linspace(-0.5,6.5,8); + clf() + subplot(2,1,1) + histplot(c, d, style=2) + xtitle("normalized histogram") + subplot(2,1,2) + histplot(c, d, normalization=%f, style=5) + xtitle("non normalized histogram") + Example #3: histogram of an exponential random sample @@ -137,6 +152,16 @@ x = linspace(0,max(Xmax),100)'; plot2d(x,lambda*exp(-lambda*x),strf="000",style=5) legend(["exponential random sample histogram" "exact density curve"]); ]]> + + lambda = 2; + X = grand(100000,1,"exp", 1/lambda); + Xmax = max(X); + clf() + histplot(40, X, style=2) + x = linspace(0,max(Xmax),100)'; + plot2d(x,lambda*exp(-lambda*x),strf="000",style=5) + legend(["exponential random sample histogram" "exact density curve"]); + diff --git a/scilab/modules/graphics/help/en_US/2d_plot/polarplot.xml b/scilab/modules/graphics/help/en_US/2d_plot/polarplot.xml index 802eb11..940d678 100644 --- a/scilab/modules/graphics/help/en_US/2d_plot/polarplot.xml +++ b/scilab/modules/graphics/help/en_US/2d_plot/polarplot.xml @@ -269,28 +269,61 @@ Example 1 - + + t= 0:.01:2*%pi; + polarplot(sin(7*t),cos(8*t)) + + Example 2 - + + t= 0:.01:2*%pi; + + clf();polarplot([sin(7*t') sin(6*t')],[cos(8*t') cos(8*t')],[1,2]) + + Example 3 - + + t = 0:0.01:2*%pi; + polarplot(t, -1 + sin(t)); + + + + Example 4 + + + theta=[0:0.02:2*%pi]'; + rho=1+0.2*cos(theta.^2) + polarplot(theta,rho,style=5) + a=gca() + a.isoview='on' + a.data_bounds=[-1.2,-1.2;1.2,01.2] + + diff --git a/scilab/modules/graphics/help/en_US/geometric_shapes/xarc.xml b/scilab/modules/graphics/help/en_US/geometric_shapes/xarc.xml index 760a6a4..d28cd03 100644 --- a/scilab/modules/graphics/help/en_US/geometric_shapes/xarc.xml +++ b/scilab/modules/graphics/help/en_US/geometric_shapes/xarc.xml @@ -59,13 +59,37 @@ Examples - + + + + + rect=[-1,-1,1,1] + plot2d(0,0,0,rect=rect,frameflag=3,axesflag=5) + xrpoly([0,0],3,1) + xarc(-1,1,2,2,0,64*360) + xarc(-1,1,2,2,0,64*360) + xstring(1,0.1,'A')//label A + xstring(-0.5,0.9,'B')//label B + xstring(-0.5,-1,'C')//label C + + See Also diff --git a/scilab/modules/statistics/help/en_US/summaries/tabul.xml b/scilab/modules/statistics/help/en_US/summaries/tabul.xml index fcbfda6..143c8d5 100644 --- a/scilab/modules/statistics/help/en_US/summaries/tabul.xml +++ b/scilab/modules/statistics/help/en_US/summaries/tabul.xml @@ -10,7 +10,7 @@ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt * --> - + tabul frequency of values of a matrix or vector @@ -88,24 +88,37 @@ Examples + + + + + n = 50000; + X = grand(n,1,"bin",70,0.5); + m = tabul(X,"i"); + clf() + plot2d3(m(:,1), m(:,2)/n) + xtitle("empirical probabilities of B(70,0.5)") + + +