diff options
author | Shashank | 2017-05-29 12:40:26 +0530 |
---|---|---|
committer | Shashank | 2017-05-29 12:40:26 +0530 |
commit | 0345245e860375a32c9a437c4a9d9cae807134e9 (patch) | |
tree | ad51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/randlib/demos/exp.dem.sce | |
download | scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2 scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip |
CMSCOPE changed
Diffstat (limited to 'modules/randlib/demos/exp.dem.sce')
-rwxr-xr-x | modules/randlib/demos/exp.dem.sce | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/modules/randlib/demos/exp.dem.sce b/modules/randlib/demos/exp.dem.sce new file mode 100755 index 000000000..ec4d5fe4e --- /dev/null +++ b/modules/randlib/demos/exp.dem.sce @@ -0,0 +1,47 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ENPC +// Copyright (C) ????-2008 - INRIA +// Copyright (C) 2010 - DIGITEO - Allan CORNET +// +// This file is released under the 3-clause BSD license. See COPYING-BSD. + + + +function [] = ExpT(n) + + function [y]=Exp(m,n,lambda) + // lambda exp(-lambda x) x>=0 + // --------------------------- + y=(-1/lambda)* log(rand(m,n,"uniform")); + endfunction + + // lambda exp(-lambda x) x>=0 + // --------------------------- + [lhs,rhs] = argn(0); + if rhs <= 0 ; n = 1000;end + lambda = 3; + y = Exp(1, n, lambda); + drawlater(); + my_handle = scf(100001); + clf(my_handle, "reset"); + demo_viewCode("exp.dem.sce"); + histplot([0:0.1:10],y,[1,1],"051"," ",[0,0,5,3]); + deff("[y]=f(x)","y=lambda*exp(-lambda*x);"); + x=[0:0.1:10]'; + plot2d(x, f(x), 1, "000"); + titre= _("Simulation of an exponential random variable"); + xtitle(titre,_("Classes"),"N(C)/Nmax"); + PolylineFillColorId = color(179,179,0); + current_axe = gca(); + current_axe.title.font_size = 3; + current_axe.background = color(232,230,200); + current_axe.children(2).children.fill_mode = "on"; + current_axe.children(2).children.background = PolylineFillColorId; + current_axe.grid = [-1 PolylineFillColorId]; + legend([_("Simulation");_("Theory")]); + drawnow(); +endfunction + +ExpT(); +clear ExpT; + |