Afonso's Basic code
- From: "Old Mac User" <chendrixstats@xxxxxxxxx>
- Date: 31 Mar 2007 09:02:12 -0700
Afonso...
Going back to your Basic code which is rooted in this discussion
http://groups.google.com/group/sci.stat.math/browse_frm/thread/0410a9b003438a95
at #30 in this long thread I find this
MY RESPONSE
Check (below) what was the algorithm I used.
What is extraordinary is your claim that you
performed similar job years ago. Changing
your mind since that date? If the values are worthless
why did you performed the calculations? This is no
sense, AT ALL! (I am not surprised , even a bit).
______licas (Luis A. Afonso)
REM "LiLLI"
CLS
PRINT " LILLI(EFORS) "
INPUT " n = "; n
INPUT " all = "; all
pi = 4 * ATN(1): c = 1 / SQR(2 * pi)
DIM x(n), xx(n), F(n)
DIM w(9001)
DEF fng (z, j) = -.5 * z ^ 2 * (2 * j + 1) /
((j + 1) * (2 * j + 3))
F(0) = 0
FOR ji = 1 TO n: F(ji) = ji / n: NEXT ji
FOR k = 1 TO all: RANDOMIZE TIMER
LOCATE 5, 50:
PRINT USING "##########"; all - k
mmaior = -1: md = 0: soma2 = 0
FOR i = 1 TO n
a = SQR(-2 * LOG(RND))
x(i) = a * COS(2 * pi * RND)
md = md + x(i) / n
soma2 = soma2 + x(i) * x(i)
NEXT i
sqd = soma2 - n * (nmd) ^ 2
: sd = SQR(sqd / n)
FOR ii = 1 TO n
x(ii) = (x(ii) - md) / sd
NEXT ii
FOR ii = 1 TO n: u = x(ii): w = 1
FOR jj = 1 TO n
IF x(jj) < u THEN w = w + 1
NEXT jj: xx(w) = u
NEXT ii
FOR tt = 1 TO n: z = xx(tt)
REM calcula FI(z)
IF z > 0 THEN kw = 0
IF z < 0 THEN kw = 1
zu = ABS(z): s = c * zu: antes = c * zu
FOR j = 0 TO 1000
xx = antes * fng(zu, j)
s = s + xx
antes = xx
IF ABS(xx) < .00005 THEN GOTO 20
NEXT j
20 IF kw = 0 THEN ff = .5 + s
IF kw = 1 THEN ff = .5 - s
b = ABS(ff - F(tt - 1))
bb = ABS(F(tt) - ff)
maior = b
IF bb > b THEN maior = bb
IF maior > mmaior THEN mmaior = maior
NEXT tt
mm = INT(1000 * mmaior + .5)
IF mm > 9000 THEN mm = 9000
w(mm) = w(mm) + 1
fff = INT(k / 50000): ff = k / 50000
IF ff <> fff THEN GOTO 1000
cc(1) = .95 * k: cc(2) = .99 * k
FOR iji = 1 TO 2
ciji = cc(iji): s = 0
FOR iij = 0 TO 9000
s = s + w(iij)
IF s > ciji THEN GOTO 100
NEXT iij
100 PRINT USING "##.### #.#### ";
iij / 1000; s / k
NEXT iji
1000 NEXT k
END
It's always helpful if you include some Comments in code. Otherwise
it's difficult to follow what's happening. Nonetheless, I see the
following.
1. The data you are generating seems to be coming from a normal
distribution. You've used a confusing variant on the Box-Mueller
method. But the essence of it is in there.
a = SQR(-2 * LOG(RND))
x(i) = a * COS(2 * pi * RND)
2. Here...
sqd = soma2 - n * (nmd) ^ 2 <---
: sd = SQR(sqd / n)
FOR ii = 1 TO n
x(ii) = (x(ii) - md) / sd
you have calculated sqd and sd but nowhere was the value of nmd
defined.
I added an <--- to identify where nmd is used. So nmd is always set to
0.
Why is this so?
3. Can you tell us exactly where the simulated confidence intervals
are calculated in this code?
And what you did with them after they were calculated?
OMU
.
- Follow-Ups:
- Re: Afonso's Basic code
- From: Luis A. Afonso
- Re: Afonso's Basic code
- From: Luis A. Afonso
- Re: Afonso's Basic code
- From: Old Mac User
- Re: Afonso's Basic code
- Prev by Date: Re: Thousands of solutions manuals
- Next by Date: Re: Afonso's Basic code
- Previous by thread: YOU ARE DEADLY WRONG Jack Tomsky
- Next by thread: Re: Afonso's Basic code
- Index(es):
Relevant Pages
|
|