Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: convolution-integral


From   "Andreas Aschbacher" <aa_surf@gmx.at>
To   statalist@hsphsun2.harvard.edu
Subject   st: convolution-integral
Date   Tue, 23 Mar 2004 10:35:53 +0100 (MET)

Dear fellows !
I want to bring forward 

 1) f1[x_]:= Exp[-(x-y)^2/(2*(s^2))];
 2) f2[x_]:= .1/(x + .1);
 3)ff[d_]:=NIntegrate[f1[d-x] f2[x],{x,0,d}];
 4) Plot[{f1[x],f2[x],ff[x]},{x,0,10}]
1) bis 4) is mathematica language for convolution-integral
/let's say y= 0 and s = 1  /
in Stata-language.
I'd like to have 
     integral(f1(d-x)*f2(x))dx   from  0 to 0.1 /d = 0.1
     integral(f1(d-x)*f2(x))dx   from  0 to 0.2 /d = 0.2
     .
     .
     .......................................................... /d = 10
in order to plot my convolution-function - that means :all integral-values
as a function
of my steps;
->I will show you what I did:
~
drop _all
set obs 100 
tempname tempd1 tempd2
scalar `tempd1'=0.1
gen double d=.
gen double conv=. 
forvalue i=1/100 {
scalar `tempd2'=`i'*`tempd1'
range x 0 `tempd1' 100 
gen double y=exp(-(`tempd2'-x)^2/2)*0.1/(x+0.1)
integ y x, gen(Sy)
replace d=`tempd2' in `i'
replace conv=Sy[100] in `i' 
drop Sy x y if 
}
gen x=d
gen f1=exp(-(`tempd2'-x)^2/2)
gen f2=0.1/(x+0.1)
line f1 x || line f2 x || line conv x
~

I don't know why it does not work !
any advice will be appreciated very much.

andreas aschbacher




-- 
+++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz +++
100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index