~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to man/eng/scicos/RAND_f.htm

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 
2
 
 
3
<!--Converted with LaTeX2HTML 2002-2-1 (1.70)
 
4
original version by:  Nikos Drakos, CBLU, University of Leeds
 
5
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
 
6
* with significant contributions from:
 
7
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
 
8
<HTML>
 
9
<HEAD>
 
10
<TITLE>Random generator </TITLE>
 
11
<META NAME="description" CONTENT="Random generator ">
 
12
<META NAME="keywords" CONTENT="main">
 
13
<META NAME="resource-type" CONTENT="document">
 
14
<META NAME="distribution" CONTENT="global">
 
15
 
 
16
<META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1">
 
17
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
 
18
 
 
19
<LINK REL="STYLESHEET" HREF="main.css">
 
20
 
 
21
</HEAD>
 
22
 
 
23
<BODY bgcolor="#FFFFFF">
 
24
 
 
25
<!--Table of Child-Links-->
 
26
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
 
27
 
 
28
<UL>
 
29
<LI><A NAME="tex2html2806"
 
30
  HREF="RAND_f.htm#SECTION00514100000000000000">Library</A>
 
31
<LI><A NAME="tex2html2807"
 
32
  HREF="RAND_f.htm#SECTION00514200000000000000">Description</A>
 
33
<LI><A NAME="tex2html2808"
 
34
  HREF="RAND_f.htm#SECTION00514300000000000000">Dialog Box</A>
 
35
<LI><A NAME="tex2html2809"
 
36
  HREF="RAND_f.htm#SECTION00514400000000000000">Default properties</A>
 
37
<LI><A NAME="tex2html2810"
 
38
  HREF="RAND_f.htm#SECTION00514500000000000000">Interfacing function</A>
 
39
<LI><A NAME="tex2html2811"
 
40
  HREF="RAND_f.htm#SECTION00514600000000000000">Computational function (type 0)</A>
 
41
</UL>
 
42
<!--End of Table of Child-Links-->
 
43
<HR>
 
44
 
 
45
<H2><A NAME="SECTION00514000000000000000"></A><A NAME="RAND_f"></A>
 
46
<BR>
 
47
Random generator 
 
48
</H2>
 
49
<DIV ALIGN="CENTER">
 
50
<!-- MATH
 
51
 $\epsfig{file=RAND_f.eps,width=90.00pt}$
 
52
 -->
 
53
<IMG
 
54
 WIDTH="143" HEIGHT="108" ALIGN="BOTTOM" BORDER="0"
 
55
 SRC="img8.gif"
 
56
 ALT="\epsfig{file=RAND_f.eps,width=90.00pt}">
 
57
</DIV>
 
58
<H3><font color="blue"><A NAME="SECTION00514100000000000000">
 
59
Library</A>
 
60
</font></H3>
 
61
Sources
 
62
 
 
63
<H3><font color="blue"><A NAME="SECTION00514200000000000000">
 
64
Description</A>
 
65
</font></H3>
 
66
 
 
67
<P>
 
68
This block is a random wave generator: each output component takes
 
69
piecewise constant random values. Every time an event is received on
 
70
the input event port, the outputs take new independent random
 
71
values. output port size is given by the size of  <B>A</B>  and  <B> B</B>  vectors     
 
72
 
 
73
<H3><font color="blue"><A NAME="SECTION00514300000000000000">
 
74
Dialog Box</A>
 
75
</font></H3>
 
76
<DIV ALIGN="CENTER">
 
77
<TABLE CELLPADDING=3 BORDER="1">
 
78
<TR><TD ALIGN="CENTER">Set Random generator block parameters</TD>
 
79
<TD></TD>
 
80
</TR>
 
81
<TR><TD ALIGN="CENTER">flag = 1 : Normal distribution A is mean and B
 
82
            deviation</TD>
 
83
<TD></TD>
 
84
</TR>
 
85
<TR><TD ALIGN="CENTER">A and B must be vector with equal sizes</TD>
 
86
<TD></TD>
 
87
</TR>
 
88
<TR><TD ALIGN="CENTER">seed is the seed of random number generator (integer<IMG
 
89
 WIDTH="18" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
 
90
 SRC="img1.gif"
 
91
 ALT="$ &lt;$">2**31)</TD>
 
92
<TD></TD>
 
93
</TR>
 
94
<TR><TD ALIGN="CENTER">flag</TD>
 
95
<TD ALIGN="CENTER">0</TD>
 
96
</TR>
 
97
<TR><TD ALIGN="CENTER">A</TD>
 
98
<TD ALIGN="CENTER">0</TD>
 
99
</TR>
 
100
<TR><TD ALIGN="CENTER">B</TD>
 
101
<TD ALIGN="CENTER">1</TD>
 
102
</TR>
 
103
<TR><TD ALIGN="CENTER">seed</TD>
 
104
<TD ALIGN="CENTER">7560437</TD>
 
105
</TR>
 
106
</TABLE>
 
107
</DIV>
 
108
 
 
109
<UL>
 
110
<LI>flag:0 or 1. 0 for uniform distribution on  <IMG
 
111
 WIDTH="83" HEIGHT="35" ALIGN="MIDDLE" BORDER="0"
 
112
 SRC="img9.gif"
 
113
 ALT="$ [A,A+B ]$"> and 1 for
 
114
  normal distribution.   
 
115
</LI>
 
116
<LI>A: scalar 
 
117
</LI>
 
118
<LI>B: scalar
 
119
</LI>
 
120
<LI>seed: seed value for a sequence of random number.
 
121
</LI>
 
122
</UL>
 
123
 
 
124
<H3><font color="blue"><A NAME="SECTION00514400000000000000">
 
125
Default properties</A>
 
126
</font></H3>
 
127
 
 
128
<UL>
 
129
<LI>always active: no
 
130
</LI>
 
131
<LI>direct-feedthrough: no
 
132
</LI>
 
133
<LI>zero-crossing: no
 
134
</LI>
 
135
<LI>mode: no
 
136
</LI>
 
137
<LI>number/sizes of inputs: 0 / 
 
138
</LI>
 
139
<LI>number/sizes of outputs: 1 / 1
 
140
</LI>
 
141
<LI>number/sizes of activation inputs: 1 / 1
 
142
</LI>
 
143
<LI>number/sizes of activation outputs: 0 / 
 
144
</LI>
 
145
<LI>continuous-time state: no
 
146
</LI>
 
147
<LI>discrete-time state: yes
 
148
</LI>
 
149
<LI>name of computational function: <EM>rndblk</EM>
 
150
</LI>
 
151
</UL>
 
152
<H3><font color="blue"><A NAME="SECTION00514500000000000000">
 
153
Interfacing function</A>
 
154
</font></H3>
 
155
<TT>scilab/macros/scicos_blocks/sources/RAND_f.sci</TT>
 
156
 
 
157
<H3><font color="blue"><A NAME="SECTION00514600000000000000">
 
158
Computational function (type 0)</A>
 
159
</font></H3>
 
160
<BR>
 
161
<PRE>      subroutine rndblk(flag,nevprt,t,xd,x,nx,z,nz,tvec,ntvec,
 
162
     &amp;     rpar,nrpar,ipar,nipar,u,nu,y,ny)
 
163
c     Copyright INRIA
 
164
 
 
165
c     Scicos block simulator
 
166
c
 
167
c     ipar(1) 
 
168
c            0 : uniform
 
169
c            1 : normal
 
170
c     rpar(1:ny)=mean
 
171
c     rpar(ny+1:2*ny)=deviation
 
172
c     rpar(2*ny+1)=dt 
 
173
c
 
174
      double precision t,xd(*),x(*),z(*),tvec(*),rpar(*),u(*),y(*)
 
175
      integer flag,nevprt,nx,nz,ntvec,nrpar,ipar(*)
 
176
      integer nipar,nu,ny
 
177
 
 
178
c
 
179
      double precision urand,sr,si,t1
 
180
 
 
181
      integer halt
 
182
      common /coshlt/ halt
 
183
c     
 
184
      if(flag.eq.1.or.flag.eq.6) then
 
185
      do 10 i=1,ny
 
186
         y(i)=rpar(i)+rpar(ny+i)*z(i+1)
 
187
 10   continue
 
188
      elseif(flag.eq.2.or.flag.eq.4) then
 
189
c     uniform
 
190
         if(ipar(1).eq.0) then
 
191
            iy=int(z(1))
 
192
            do 20 i=1,nz-1
 
193
               z(i+1)=urand(iy)
 
194
 20         continue
 
195
         else
 
196
            iy=int(z(1))
 
197
c     normal
 
198
            do 30 i=1,nz-1
 
199
 75            sr=2.0d+0*urand(iy)-1.0d+0
 
200
               si=2.0d+0*urand(iy)-1.0d+0
 
201
               t1 = sr*sr+si*si
 
202
               if (t1 .gt. 1.0d+0) go to 75
 
203
               z(i+1) = sr*sqrt(-2.0d+0*log(t1)/t1)
 
204
 30         continue
 
205
         endif
 
206
         z(1)=iy
 
207
c         if(ntvec.eq.1) tvec(1)=t+rpar(2*(nz-1)+1)
 
208
      endif
 
209
      return
 
210
      end
 
211
</PRE>
 
212
<HR>
 
213
<ADDRESS>
 
214
Ramine Nikoukhah
 
215
2004-06-22
 
216
</ADDRESS>
 
217
</BODY>
 
218
</HTML>