Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15432 > unrolled thread
| Started by | bruce.colletti@gmail.com |
|---|---|
| First post | 2013-09-14 09:49 +0000 |
| Last post | 2013-09-15 10:59 +0000 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
FindRoot bruce.colletti@gmail.com - 2013-09-14 09:49 +0000
Re: FindRoot "Dr. Wolfgang Hintze" <weh@snafu.de> - 2013-09-15 10:59 +0000
Re: FindRoot bruce.colletti@gmail.com - 2013-09-15 10:59 +0000
| From | bruce.colletti@gmail.com |
|---|---|
| Date | 2013-09-14 09:49 +0000 |
| Subject | FindRoot |
| Message-ID | <l11bf5$iss$1@smc.vnet.net> |
Re 9.0.1 under Windows 7.
The code below is extracted from another source.
Part I below returns 289 even though n is never given a value. Why does the module return a value and in particular, what does 289 mean?
Part II doesn't return a value (as expected). I don't see why Part I returns a value but not Part II.
Thanks.
Bruce
In[1]:=
(* Part I *)
f[n_,p1_,p2_]:=Sqrt[2n](ArcSin@Sqrt[p1-1/(2n)]-ArcSin@Sqrt[p2+1/(2n)]);
myModule1[\[Alpha]_,\[Beta]_]:=Module[{A=ConstantArray["",{9,9}],n,powerEST,p1=0.2,p2=0.1},
If[
p1>p2,
powerEST=SurvivalFunction[NormalDistribution[f[n,0.2,0.1],1],Quantile[NormalDistribution[],1-\[Alpha]]];
A[[IntegerPart[10(p1-0.1)],IntegerPart[10p2]]]=Ceiling[n/.FindRoot[powerEST-(1-\[Beta]),{n,40}]]
]
];
myModule1[0.05,0.05]
Out[3]= 289
In[4]:=
(* Part II *)
myModule2[\[Alpha]_,\[Beta]_]:=Module[{A=ConstantArray["",{9,9}],n},
SurvivalFunction[NormalDistribution[f[n,0.2,0.1],1],Quantile[NormalDistribution[],1-\[Alpha]]]
];
myModule2[0.05,0.05]
Out[5]= 1/2 Erfc[(1.64485 -Sqrt[2] Sqrt[n$272] (ArcSin[Sqrt[0.2 -1/(2 n$272)]]-ArcSin[Sqrt[0.1 +1/(2 n$272)]]))/Sqrt[2]]
[toc] | [next] | [standalone]
| From | "Dr. Wolfgang Hintze" <weh@snafu.de> |
|---|---|
| Date | 2013-09-15 10:59 +0000 |
| Message-ID | <l143u1$pr5$1@smc.vnet.net> |
| In reply to | #15432 |
Am Samstag, 14. September 2013 11:49:25 UTC+2 schrieb bruce.c...@gmail.com:
> Re 9.0.1 under Windows 7.
>
>
>
> The code below is extracted from another source.
>
>
>
> Part I below returns 289 even though n is never given a value. Why does the module return a value and in particular, what does 289 mean?
>
>
>
> Part II doesn't return a value (as expected). I don't see why Part I returns a value but not Part II.
>
>
>
> Thanks.
>
>
>
> Bruce
>
>
>
>
>
> In[1]:=
>
> (* Part I *)
>
> f[n_,p1_,p2_]:=Sqrt[2n](ArcSin@Sqrt[p1-1/(2n)]-ArcSin@Sqrt[p2+1/(2n)]);
>
>
>
> myModule1[\[Alpha]_,\[Beta]_]:=Module[{A=ConstantArray["",{9,9}],n,powerEST,p1=0.2,p2=0.1},
>
> If[
>
> p1>p2,
>
> powerEST=SurvivalFunction[NormalDistribution[f[n,0.2,0.1],1],Quantile[NormalDistribution[],1-\[Alpha]]];
>
>
>
> A[[IntegerPart[10(p1-0.1)],IntegerPart[10p2]]]=Ceiling[n/.FindRoot[powerEST-(1-\[Beta]),{n,40}]]
>
> ]
>
> ];
>
>
>
> myModule1[0.05,0.05]
>
> Out[3]= 289
>
> In[4]:=
>
> (* Part II *)
>
> myModule2[\[Alpha]_,\[Beta]_]:=Module[{A=ConstantArray["",{9,9}],n},
>
> SurvivalFunction[NormalDistribution[f[n,0.2,0.1],1],Quantile[NormalDistribution[],1-\[Alpha]]]
>
> ];
>
>
>
> myModule2[0.05,0.05]
>
> Out[5]= 1/2 Erfc[(1.64485 -Sqrt[2] Sqrt[n$272] (ArcSin[Sqrt[0.2 -1/(2 n$272)]]-ArcSin[Sqrt[0.1 +1/(2 n$272)]]))/Sqrt[2]]
In part 1 n is in fact assigned a value, viz. the initial values 40 in FindRoot.
Having found the root close to 289 Returns this value from the module.
Best regards,
Wolfgang
[toc] | [prev] | [next] | [standalone]
| From | bruce.colletti@gmail.com |
|---|---|
| Date | 2013-09-15 10:59 +0000 |
| Message-ID | <l143ul$pr7$1@smc.vnet.net> |
| In reply to | #15432 |
Folks, please ignore my post. I've discovered the problem: my printer made a semicolon look like a comma -- and we know the difference this makes incoding! I stressed over the printed code and not the displayed one. Problem has been solved. Sorry for the false alarm.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web