Message Boards Message Boards

0
|
5803 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:
GROUPS:

ListLogLogPlot problem on second run

Posted 11 years ago
Hello everyone,
So I  wrote the following code to plot a pdf and transmission line cascade model. 
 \[Lambda] = 0.7;
 
 n = 2000;
 x = 1;
 (*Boral Tanner distribution*)
 BTD[r_, x_, \[Lambda]_] := (x*\[Lambda] (r \[Lambda] )^(r - x - 1)) (E^(-r*\[Lambda] )/(r - x)!);
 (*Where r is the total number of failure, \x is the initial number of failure,  \[Lambda] is the mean propogation*)
 
 BTDdist[x_, \[Lambda]_, n_] := Table[BTD[r, x, \[Lambda]], {r, 1, n}] // N

(*  distribution of BTD  omitting BTD=0*)

BTDdistdrop[x_, \[Lambda]_, n_] := Drop[Table[BTD[r, x, \[Lambda]], {r, 1, n}], 1] // N

(* BTD for r>1 conditioned on r not zero *)
BTDdistcond[x_, \[Lambda]_, n_] := BTDdistdrop[x, \[Lambda], n]/(1 - E^(-x))


Manipulate[
Column@{ListLogLogPlot[BTDdistcond[\[Lambda], \[Lambda], 2000], Joined -> True, PlotRange -> {All, {0.000001`, 1}}], ControlActive[\[Lambda], Monitor[For[i = 1, i <= 2, Pause[10]; i++], NestWhileList[nextstage[#, \[Lambda]] &, 1, # != 0 &]]]}, {{\[Lambda], .01, "Lamda"}, 0.01, 1}]

The program runs fine when I evaluate it but once I close the Mathematica program and reopen this code it gives me the following error. And to make the error go away I have to reevaluate it everytime. Any thoughts? 
ListLogLogPlot::lpn: BTDdistcond[0.01,0.01,2000] is not a list of numbers or pairs of numbers. >>
POSTED BY: Hamzah Abeer
2 Replies
You may want to look into the SaveDefinitions option for Manipulate. Code such as
f[x_, a_] := a x^2

Manipulate[Plot[f[x, a], {x, 0, 1}], {a, 0, 10}, SaveDefinitions -> True]
will preserve the defiition of f for the manipulate.
POSTED BY: Jason Grigsby
This is expected behavior:

The first time you run it it will evaluate your definitions of BTDdistcond first and then execute Manipulate[.....].
If you reopen the file (closing Mathematica) the active control (the manipulate) will try to show you results, namely it will try to plot BTDdistcond[?, ?, 2000] but it can't because BTDdistcond is not yet evaluated by the kernel and does not know this definition.
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract