- #1
Aner
- 9
- 0
Hi,
I have a problem in my program and I cannot figure it out.
In the last post I had a problem about some arrays, I perfectly resolved it thanks to you, but now my problem is a little bit subtle. I have a subroutine(here I'll post it has a program )that generates random numbers in order to create errors so that those must have a Gaussian distribution and it is perfect, the program works perfectly, I can have a really nice Gaussian until I centred my points (that is what I must do to associated the errors to my data). After I centred the points I get a weird accumulation of point near x=1 that I can't explain.
Here is the program I'm talking about
The file that it reads is a column of data that I generate in my main program. I printed two files, one with the already centred points and one with the not centred ones. Now I would expect those two sets of points to give a Gaussian distribution but a you can see those are pretty different.
This pron(f)=2*0.1*(m(f)-0.5) is the line that I use to centre my points, it's something that we did in class with the teacher. I even thought that maybe it was the minus sign that was bothering fortran and I did some experiments like changing it with a plus and defining m(f) as negative. In the main program if I use the centred points I have a "lack" of precision, if I expect my output to be -3 I'll get -2.993... with an error of order 10-7 when with the not centred ones I get -3.001... with an error of order 10 -3.
I can't understand the problem if there is one or it is just me, maybe I'm missing something.
Thanks in advanced.
I have a problem in my program and I cannot figure it out.
In the last post I had a problem about some arrays, I perfectly resolved it thanks to you, but now my problem is a little bit subtle. I have a subroutine(here I'll post it has a program )that generates random numbers in order to create errors so that those must have a Gaussian distribution and it is perfect, the program works perfectly, I can have a really nice Gaussian until I centred my points (that is what I must do to associated the errors to my data). After I centred the points I get a weird accumulation of point near x=1 that I can't explain.
Here is the program I'm talking about
Fortran:
Program gauss
implicit none
character(len=6)::gaussn
real,dimension(10000)::m,a,ltot,pron
REAL::x,l
INTEGER::i,n,k,p,j,fn=10000
print*,"scrivere il nome del file"
read*,gaussn OPEN(UNIT=1,FILE=gaussn)
do f=1,n
read(1,*)m(f)
pron(f)=2*0.1*(m(f)-0.5)
end do
close (unit=1)a=0
l=0.1/700do i=1,np=int(pron(i)/l)
a(p+(n/2+1))=a(p+(n/2+1))+1
!a(p)=a(p)+1
end do
do j=1,n
ltot(j)=-(n/2.0)+j
write(unit=15,fmt=*)ltot(j),a(j)
end do
end program gauss
This pron(f)=2*0.1*(m(f)-0.5) is the line that I use to centre my points, it's something that we did in class with the teacher. I even thought that maybe it was the minus sign that was bothering fortran and I did some experiments like changing it with a plus and defining m(f) as negative. In the main program if I use the centred points I have a "lack" of precision, if I expect my output to be -3 I'll get -2.993... with an error of order 10-7 when with the not centred ones I get -3.001... with an error of order 10 -3.
I can't understand the problem if there is one or it is just me, maybe I'm missing something.
Thanks in advanced.