Generate table/matrix with test data

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Generate table/matrix with test data

theozh
sometimes it's helpful to generate some test or dummy data.

I hoped that I can create some test data (columns and/or matrices) with
"set table".

Is there a way to generate N-column or M x N-matrix random data?
e.g. like
0.10 0.45 0.91 0.50 0.55
0.57 0.19 0.74 0.28 0.06
0.85 0.09 0.27 0.27 0.80
0.08 0.31 0.08 0.66 0.43
0.77 0.80 1.00 0.14 0.50

For example, I expected the following code to produce a 5x5 matrix of
random data.

reset
set samples 5
set table "Test.dat"
plot rand(0):rand(0):rand(0):rand(0):rand(0) with table
# or maybe
# plot rand(0),rand(0),rand(0),rand(0),rand(0) with table
# or "splot ... something"
unset table

But this seems not to work like this.
I also tried "set parametric" like in the "random-demos"...


While fiddling around I found that the following code would create such
a 5x5 matrix:

####### generate 5x5 matrix of random numbers
reset
$Data <<EOD
1 1
2 1
3 1
4 1
5 1
EOD

set table "Test.dat"
plot $Data using \
($2*rand(0)):($2*rand(0)):($2*rand(0)):($2*rand(0)):($2*rand(0)) \
with table

unset table
####### EOF


Two questions:

1)
How would I do this for a 1000x1000 matrix?
Repeating ($2*rand(0)) a thousand times...???

2)
Ideally, I also wanted the data to be separated by TAB instead of space.
So, if I additionally set in the above working code

 set datafile separator "\t"

I get the error message:  "...x range is invalid"


Any ideas?


------------------------------------------------------------------------------
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Generate table/matrix with test data

thse
if you want an simple table use the "sprintf" function to generate
one line and then "print" it:

reset
n=1000
set print "Test.dat"
do for [i=1:n] {
   tmp = ""
   do for [j=1:n] {
      tmp = tmp.sprintf("%1.2f\t",rand(0))      
   }
   print tmp
}
unset print
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Generate table/matrix with test data

theozh
Thanks a lot thse!
Ah, so easy!
Sorry, haven't thought about the "obvious" print function.

------------------------------------------------------------------------------
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Generate table/matrix with test data

Ethan A Merritt-2
In reply to this post by theozh
On Mon, Aug 8, 2016 at 12:22 AM, theozh <[hidden email]> wrote:

> sometimes it's helpful to generate some test or dummy data.
>
> I hoped that I can create some test data (columns and/or matrices) with
> "set table".
>

Sure


> For example, I expected the following code to produce a 5x5 matrix of
> random data.
>
> reset
> set samples 5
> set table "Test.dat"
> plot rand(0):rand(0):rand(0):rand(0):rand(0) with table
>

Close.  But you haven't actually given it a nominal data source or
function to plot.  This should work:

  set sample 5
  set table
  plot x using (rand(0)):(rand(0)):(rand(0)):(rand(0)):(rand(0)) with table

   Ethan
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Generate table/matrix with test data

theozh

> Close.  But you haven't actually given it a nominal data source or
> function to plot.  This should work:
>
>   set sample 5
>   set table
>   plot x using (rand(0)):(rand(0)):(rand(0)):(rand(0)):(rand(0)) with table
>
...not yet. My gnuplot (V5.0 0) complains about the "using" as
 "unexpected or unrecognized token"

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Generate table/matrix with test data

Ethan A Merritt-2
On Mon, Aug 8, 2016 at 12:34 PM, theozh <[hidden email]> wrote:

>
> > Close.  But you haven't actually given it a nominal data source or
> > function to plot.  This should work:
> >
> >   set sample 5
> >   set table
> >   plot x using (rand(0)):(rand(0)):(rand(0)):(rand(0)):(rand(0)) with
> table
> >
> ...not yet. My gnuplot (V5.0 0) complains about the "using" as
>  "unexpected or unrecognized token"
>


Sorry.  Thinko/typo. That should have been

plot '+' using (rand(0)):(rand(0)):(rand(0)):(rand(0)):(rand(0)) with table
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Generate table/matrix with test data

theozh
Thanks!
Learned again... I was not yet familiar with plot '+' and '++'
Now, it works as expected.

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
gnuplot-info mailing list
[hidden email]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
Loading...