[hp50g] how enter the rand function for graphing?
|
09-27-2022, 04:28 PM
Post: #1
|
|||
|
|||
[hp50g] how enter the rand function for graphing?
hello
i want to trace the graph of this equation y1(x)= rand() when i choose the "rand" function in menu math/prob it doesnt display "rand" but immediately it displays a random number (for example .25457641..) so when i draw the y1 function it is a cunstant line and not a random value for each x i don't know if i am clear.. my question: how to not have a value when i enter the rand function in y1(x) equation? thx |
|||
09-28-2022, 01:17 PM
Post: #2
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
In similar (but not identical) situations, I created a function Y=<<DROP RAND>> and call it as Y(N) where N is just 1,2,3,4... on different calls.
|
|||
09-28-2022, 03:45 PM
Post: #3
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
(09-28-2022 01:17 PM)ttw Wrote: In similar (but not identical) situations, I created a function Y=<<DROP RAND>> and call it as Y(N) where N is just 1,2,3,4... on different calls. i'm not sure to understand how to do. if i stock the <<DROP RAND>> program to a Y variable and call it when i need it to write the Y1(x) equation, then when i type the draw button i have a drop error "too few arguments" message. with the hp-prime when i enter the random function it works and draws the graph immediately (same for casio and ti calculators). why it is not possible in a so simple way with the hp50g? |
|||
09-30-2022, 10:24 PM
Post: #4
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
The program « → X « RAND » » works fine, but when you try to get a graphic it, you get something like y = constant. The only thing that worked for me, was to use X to set a new seed:
« → X « RDZ RAND » » I stored this program in variable R and set 'Y1(X)=R(X)' |
|||
10-02-2022, 07:47 PM
(This post was last modified: 10-02-2022 08:11 PM by Gil.)
Post: #5
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
I tried and draw the random graph according to last post.
with « → X « X RDZ RAND » ». We find a pattern in N shape. Is it really what should be expected by random numbers? I tried instead : « 1 1000 START RAND NEXT { 500 2 } —>ARRY ». And used the scatter function with the above data. Then auto for the window screen. Note that, because of lack of space, the minimum that appears for the x ax is 1.4. When editing that value, we see of course that it's in fact 1.4E-2. Regards, Gil |
|||
10-06-2022, 11:29 PM
Post: #6
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
Sorry about missing the X in mi program, I added a RAND 100 so the graphic is not always the same.
« → X « X 100 RAND * * IP RDZ RAND » » |
|||
10-07-2022, 05:20 AM
(This post was last modified: 10-07-2022 05:26 AM by Gil.)
Post: #7
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
With your above defined function, is it really a random function when we look at the attached file?
It seems that we see like a sinus trend : it goes up for a while, then down for some time, to start afterwards again, to some extent the up & down pattern. Or perhaps I am mistaken. Regards, Gil |
|||
10-08-2022, 03:31 PM
Post: #8
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
Hello Gil, you are not mistaken, I am getting a different graphic than yours, but is the same graphic every time, at least you play with the RAND command for a few times. My solution is not pretty, I used the last digits of the command TIME to generate a number for RDZ command.
« → X « TIME 8 ALOG * FP 100 * X * RDZ RAND » » |
|||
10-08-2022, 10:33 PM
(This post was last modified: 10-08-2022 10:41 PM by Gil.)
Post: #9
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
Your programs are interesting, above all the last one, but
the "problem" seems to be in the RDZ command: See the result of « 1 20 FOR i i DUP RDZ RAND SWAP —>TAG NEXT » :1: .731362440213 :2: .431362440213 :3: .131362440213 : 4: .831362440213 :5: .531362440213 :6: .231362440213 : 7: .931362440213 :8: .631362440213 :9: .331362440213 : 10: .759873749497 :11: .429873749497 :12: 9.98737494978E-2 : 13: .769873749497 :14: .439873749497 :15: .109873749497 : 16: .779873749497 :17: .449873749497 :18: .119873749497 : 19: .789873749497 :20: .459873749497 and observe how the digits repeat themselves. Regards, Gil Campart |
|||
10-09-2022, 12:35 PM
(This post was last modified: 10-09-2022 12:36 PM by ijabbott.)
Post: #10
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
(10-08-2022 10:33 PM)Gil Wrote: Your programs are interesting, above all the last one, but The "problem" is that the RDZ command is being misused. It is only supposed to be called once to begin a pseudo-random sequence. — Ian Abbott |
|||
10-09-2022, 05:09 PM
Post: #11
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
(09-27-2022 04:28 PM)ahahah Wrote: my question: how to not have a value when i enter the rand function in y1(x) equation? RAND on the 50g is considered a command as opposed to a function. As a result, you can't use it in an algebraic expression for plotting. You can, however, still plot its result. You just need to enter a program instead of a function for plotting. Start off with a "clean slate". If you already have any of these variables in the current directory of your 50g, either create a new (empty) directory or delete them from the current one: X Y EQ PPAR ZPAR Note that if any of the above are also in your HOME directory, those will need to be deleted as well to make sure that lingering variables in the search path aren't confusing things. Create the small program to be plotted: « RAND » Save the above program in the reserved variable "EQ": STEQ Set the X-range to match the display width (this will also create a default PPAR for a function): 1 131 XRNG The RAND result will never be < 0 or >= 1. So set the Y-range accordingly to maximize the vertical coverage: 0 1 YRNG The default for a function graph is to plot every other column, but in this case we want every column plotted: 1 RES We don't need the axes drawn for this: -29 SF Likewise, we just want the points. Not the lines between the points: -31 SF Clear any previous plots from PICT: ERASE Left-shift<HOLD>-D will activate the PLOT SETUP dialog. Press "F/F6" to DRAW the plot. This should result in a random pattern of dots across the PICT image. The only reason you would want to use RDZ here is if you want to show an example of the output that you would want to repeat exactly. In that case, you would provide a number (the more digits the better) to RDZ immediately before any drawing is executed in order to have predictable results. As an example, this is the resulting plot when drawing is prefaced by "123456789 RDZ": You should be able to replicate that exact pattern by executing 123456789 RDZ right before ERASEing and DRAWing. |
|||
10-12-2022, 10:11 PM
(This post was last modified: 10-12-2022 10:30 PM by Gil.)
Post: #12
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
Contrarily to what I thought, it works fine.
Thank you. Regards, Gil |
|||
10-12-2022, 11:04 PM
Post: #13
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
Graphing with the 50g is very flexible, but that flexibility comes at the cost of having many details to sort out in order to get the graph you need. And when you finally get the graph the way you want it, the limited resolution of the display of the 50g (by today's standards) rarely matches the value of the effort. The "canvas" can be expanded with PDIM to get more resolution, but then you either have to scroll PICT on the calculator, or transfer the image to something else in order to see the full picture. Neither choice is very good.
This specific example should normally be approached as a SCATTER plot instead of a FUNCTION, but going that route would require getting the data into a ΣDAT object. Treating it as a function instead actually simplifies the setup, but does require that some default settings are changed so as not to "connect the dots" when it's drawn. We are in essence forcing the system to plot points in the same way it would if this were a scatter plot, but without having to populate ΣDAT. That makes this example a bit misleading, but it still works. |
|||
10-13-2022, 07:06 AM
Post: #14
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
A pity anyway that HP did not adapt/keep the spirit of the HP50G, with its objects and directories or menus & directories boxes, with free variable names, to the graphing capabilities of the CX.
For that, I do hold on my old fashioned HP50G, the CX remaining in a drawer. By the way, how would you increase the number of graphed points with your "trick" «RAND » STEQ? Regards, Gil |
|||
10-13-2022, 12:21 PM
Post: #15
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
(10-13-2022 07:06 AM)Gil Wrote: By the way, how would you increase the number of graphed points with your "trick" «RAND » STEQ? When plotting a function, the graphing engine of the 50g looks at all of the given parameters (mostly residing in the PPAR object for this scenario), then repeatedly sets the value of the independent variable (X in this case) to what it has determined as the current value to plot. After setting X, it calls the program stored in EQ. Whatever the result is from that program becomes the Y value for the given iteration. In this case, we don't really care what X is, so it doesn't need to show up in the EQ program. Getting more points plotted becomes a matter of changing the environment so that the \<< RAND \>> program gets called more times. The previous program used a "canvas" with the default dimensions (131x80). Let's say that we want to increase the size of that canvas to 500x500, with plotted points covering that entire image. Increasing the size of the canvas will inherently spread out the results, so I'll apply multiple plots to provide more points in the final graph: Code: \<< Here's the final output that the above program generates: |
|||
10-13-2022, 12:27 PM
Post: #16
|
|||
|
|||
RE: [hp50g] how enter the rand function for graphing?
Very clearly explained and will full details.
A great thank for your painstaking. Regards, Gil |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)