# Synthetic Data Generator

In many circumstances, it is necessary to have a test dataset to evaluate alternative implementation approaches or to perform benchmarks. It is often required that such a data set have particular requirements in size or in the intrinsic characteristics of its data. Even if a real-world dataset could be available, it may be not ideal for such experiments for multiple reasons. Therefore, a synthetic data generator that could be customized to produce data according to the given requirements is often the best solution. Obviously, experiments with synthetic data should be complemented with experiments with real-world data to have a thorough understanding of the problem at hand.

MobilityDB provides a simple synthetic data generator that can be used for such purposes. In particular, such a data generator was used for generating the database used for the regression tests in MobilityDB. The data generator is programmed in PL/pgSQL so it can be easily customized. It is located in the directory `datagen` in the repository. In this appendix, we briefly introduce the basic functionality of the generator. We first list the functions generating random values for the various PostgreSQL, PostGIS, and MobilityDB data types, and then give examples how to use these functions for generating tables of such values. The parameters of the functions are not specified, refer to the source files where detailed explanations about the various parameters can be found.

## Generator for PostgreSQL Types

- `random_bool`: Generate a random boolean

- `random_int`: Generate a random integer

- `random_int_array`: Generate a random array of integers

- `random_int4range`: Generate a random integer range

- `random_float`: Generate a random float

- `random_float_array`: Generate a random array of floats

- `random_text`: Generate a random text

- `random_timestamptz`: Generate a random timestamp with time zone

- `random_timestamptz_array`: Generate a random array of timestamps with time zone

- `random_minutes`: Generate a random interval of minutes

- `random_tstzrange`: Generate a random timestamp with time zone range

- `random_tstzrange_array`: Generate a random array of timestamp with time zone ranges

## Generator for PostGIS Types

- `random_geom_point`: Generate a random 2D geometric point

- `random_geom_point3D`: Generate a random 3D geometric point

- `random_geog_point`: Generate a random 2D geographic point

- `random_geog_point3D`: Generate a random 3D geographic point

- `random_geom_point_array`: Generate a random array of 2D geometric points

- `random_geom_point3D_array`: Generate a random array of 3D geometric points

- `random_geog_point_array`: Generate a random array of 2D geographic points

- `random_geog_point3D_array`: Generate a random array of 3D geographic points

- `random_geom_linestring`: Generate a random geometric 2D linestring

- `random_geom_linestring3D`: Generate a random geometric 3D linestring

- `random_geog_linestring`: Generate a random geographic 2D linestring

- `random_geog_linestring3D`: Generate a random geographic 3D linestring

- `random_geom_polygon`: Generate a random geometric 2D polygon without holes

- `random_geom_polygon3D`: Generate a random geometric 3D polygon without holes

- `random_geog_polygon`: Generate a random geographic 2D polygon without holes

- `random_geog_polygon3D`: Generate a random geographic 3D polygon without holes

- `random_geom_multipoint`: Generate a random geometric 2D multipoint

- `random_geom_multipoint3D`: Generate a random geometric 3D multipoint

- `random_geog_multipoint`: Generate a random geographic 2D multipoint

- `random_geog_multipoint3D`: Generate a random geographic 3D multipoint

- `random_geom_multilinestring`: Generate a random geometric 2D multilinestring

- `random_geom_multilinestring3D`: Generate a random geometric 3D multilinestring

- `random_geog_multilinestring`: Generate a random geographic 2D multilinestring

- `random_geog_multilinestring3D`: Generate a random geographic 3D multilinestring

- `random_geom_multipolygon`: Generate a random geometric 2D multipolygon without holes

- `random_geom_multipolygon3D`: Generate a random geometric 3D multipolygon without holes

- `random_geog_multipolygon`: Generate a random geographic 2D multipolygon without holes

- `random_geog_multipolygon3D`: Generate a random geographic 3D multipolygon without holes

## Generator for MobilityDB Span, Time, and Box Types

- `random_intspan`: Generate a random integer span

- `random_floatspan`: Generate a random float span

- `random_tstzspan`: Generate a random `tstzspan`

- `random_tstzspan_array`: Generate a random array of `tstzspan` values

- `random_tstzset`: Generate a random `tstzset`

- `random_tstzspanset`: Generate a random `tstzspanset`

- `random_tbox`: Generate a random `tbox`

- `random_stbox`: Generate a random 2D `stbox`

- `random_stbox3D`: Generate a random 3D `stbox`

- `random_geodstbox`: Generate a random 2D geodetic `stbox`

- `random_geodstbox3D`: Generate a random 3D geodetic `stbox`

## Generator for MobilityDB Temporal Types

- `random_tbool_inst`: Generate a random temporal Boolean of instant subtype

- `random_tint_inst`: Generate a random temporal integer of instant subtype

- `random_tfloat_inst`: Generate a random temporal float of instant subtype

- `random_ttext_inst`: Generate a random temporal text of instant subtype

- `random_tgeompoint_inst`: Generate a random temporal geometric 2D point of instant subtype

- `random_tgeompoint3D_inst`: Generate a random temporal geometric 3D point of instant subtype

- `random_tgeogpoint_inst`: Generate a random temporal geographic 2D point of instant subtype

- `random_tgeogpoint3D_inst`: Generate a random temporal geographic 3D point of instant subtype

- `random_tbool_discseq`: Generate a random temporal Boolean of sequence subtype and discrete interpolation

- `random_tint_discseq`: Generate a random temporal integer of sequence subtype and discrete interpolation

- `random_tfloat_discseq`: Generate a random temporal float of sequence subtype and discrete interpolation

- `random_ttext_discseq`: Generate a random temporal text of sequence subtype and discrete interpolation

- `random_tgeompoint_discseq`: Generate a random temporal geometric 2D point of sequence subtype and discrete interpolation

- `random_tgeompoint3D_discseq`: Generate a random temporal geometric 3D point of sequence subtype and discrete interpolation

- `random_tgeogpoint_discseq`: Generate a random temporal geographic 2D point of sequence subtype and discrete interpolation

- `random_tgeogpoint3D_discseq`: Generate a random temporal geographic 3D point of sequence subtype and discrete interpolation

- `random_tbool_seq`: Generate a random temporal Boolean of sequence subtype

- `random_tint_seq`: Generate a random temporal integer of sequence subtype

- `random_tfloat_seq`: Generate a random temporal float of sequence subtype

- `random_ttext_seq`: Generate a random temporal text of sequence subtype

- `random_tgeompoint_seq`: Generate a random temporal geometric 2D point of sequence subtype

- `random_tgeompoint3D_seq`: Generate a random temporal geometric 3D point of sequence subtype

- `random_tgeogpoint_seq`: Generate a random temporal geographic 2D point of sequence subtype

- `random_tgeogpoint3D_seq`: Generate a random temporal geographic 3D point of sequence subtype

- `random_tbool_seqset`: Generate a random temporal Boolean of sequence set subtype

- `random_tint_seqset`: Generate a random temporal integer of sequence set subtype

- `random_tfloat_seqset`: Generate a random temporal float of sequence set subtype

- `random_ttext_seqset`: Generate a random temporal text of sequence set subtype

- `random_tgeompoint_seqset`: Generate a random temporal geometric 2D point of sequence set subtype

- `random_tgeompoint3D_seqset`: Generate a random temporal geometric 3D point of sequence set subtype

- `random_tgeogpoint_seqset`: Generate a random temporal geographic 2D point of sequence set subtype

- `random_tgeogpoint3D_seqset`: Generate a random temporal geographic 3D point of sequence set subtype

## Generation of Tables with Random Values

The files `create_test_tables_temporal.sql` and `create_test_tables_tpoint.sql` provide usage examples for the functions generating random values listed above. For example, the first file defines the following function.

    CREATE OR REPLACE FUNCTION create_test_tables_temporal(size integer DEFAULT 100)
    RETURNS text AS $$
    DECLARE
      perc integer;
    BEGIN
    perc := size * 0.01;
    IF perc < 1 THEN perc := 1; END IF;

    -- ... Table generation ...

    RETURN 'The End';
    END;
    $$ LANGUAGE 'plpgsql';

The function has a `size` parameter that defines the number of rows in the tables. If not provided, it creates by default tables of 100 rows. The function defines a variable `perc` that computes the 1% of the size of the tables. This parameter is used, for example, for generating tables having 1% of null values. We illustrate next some of the commands generating tables.

The creation of a table `tbl_float` containing random `float` values in the range [0,100] with 1% of null values is given next.

    CREATE TABLE tbl_float AS
    /* Add perc NULL values */
    SELECT k, NULL AS f
    FROM generate_series(1, perc) AS k UNION
    SELECT k, random_float(0, 100)
    FROM generate_series(perc+1, size) AS k;

The creation of a table `tbl_tbox` containing random `tbox` values where the bounds for values are in the range [0,100] and the bounds for timestamps are in the range [2001-01-01, 2001-12-31] is given next.

    CREATE TABLE tbl_tbox AS
    /* Add perc NULL values */
    SELECT k, NULL AS b
    FROM generate_series(1, perc) AS k UNION
    SELECT k, random_tbox(0, 100, '2001-01-01', '2001-12-31', 10, 10)
    FROM generate_series(perc+1, size) AS k;

The creation of a table `tbl_floatspan` containing random `floatspan` values where the bounds for values are in the range [0,100] and the maximum difference between the lower and the upper bounds is 10 is given next.

    CREATE TABLE tbl_floatspan AS
    /* Add perc NULL values */
    SELECT k, NULL AS f
    FROM generate_series(1, perc) AS k UNION
    SELECT k, random_floatspan(0, 100, 10)
    FROM generate_series(perc+1, size) AS k;

The creation of a table `tbl_tstzset` containing random `tstzset` values having between 5 and 10 timestamps where the timestamps are in the range [2001-01-01, 2001-12-31] and the maximum interval between consecutive timestamps is 10 minutes is given next.

    CREATE TABLE tbl_tstzset AS
    /* Add perc NULL values */
    SELECT k, NULL AS ts
    FROM generate_series(1, perc) AS k UNION
    SELECT k, random_tstzset('2001-01-01', '2001-12-31', 10, 5, 10)
    FROM generate_series(perc+1, size) AS k;

The creation of a table `tbl_tstzspan` containing random `tstzspan` values where the timestamps are in the range [2001-01-01, 2001-12-31] and the maximum difference between the lower and the upper bounds is 10 minutes is given next.

    CREATE TABLE tbl_tstzspan AS
    /* Add perc NULL values */
    SELECT k, NULL AS p
    FROM generate_series(1, perc) AS k UNION
    SELECT k, random_tstzspan('2001-01-01', '2001-12-31', 10)
    FROM generate_series(perc+1, size) AS k;

The creation of a table `tbl_geom_point` containing random `geometry` 2D point values, where the x and y coordinates are in the range [0, 100] and in SRID 3812 is given next.

    CREATE TABLE tbl_geom_point AS
    SELECT 1 AS k, geometry 'SRID=3812;point empty' AS g UNION
    SELECT k, random_geom_point(0, 100, 0, 100, 3812)
    FROM generate_series(2, size) k;

Notice that the table contains an empty point value. If the SRID is not given it is set by default to 0.

The creation of a table `tbl_geog_point3D` containing random `geography` 3D point values, where the x, y, and z coordinates are, respectively, in the ranges [-10, 32], [35, 72], and [0, 1000] and in SRID 7844 is given next.

    CREATE TABLE tbl_geog_point3D AS
    SELECT 1 AS k, geography 'SRID=7844;pointZ empty' AS g UNION
    SELECT k, random_geog_point3D(-10, 32, 35, 72, 0, 1000, 7844)
    FROM generate_series(2, size) k;

Notice that latitude and longitude values are chosen to approximately cover continental Europe. If the SRID is not given it is set by default to 4326.

The creation of a table `tbl_geom_linestring` containing random `geometry` 2D linestring values having between 5 and 10 vertices, where the x and y coordinates are in the range [0, 100] and in SRID 3812 and the maximum difference between consecutive coordinate values is 10 units in the underlying SRID is given next.

    CREATE TABLE tbl_geom_linestring AS
    SELECT 1 AS k, geometry 'linestring empty' AS g UNION
    SELECT k, random_geom_linestring(0, 100, 0, 100, 10, 5, 10, 3812)
    FROM generate_series(2, size) k;

The creation of a table `tbl_geom_linestring` containing random `geometry` 2D linestring values having between 5 and 10 vertices, where the x and y coordinates are in the range [0, 100] and the maximum difference between consecutive coordinate values is 10 units in the underlying SRID is given next.

    CREATE TABLE tbl_geom_linestring AS
    SELECT 1 AS k, geometry 'linestring empty' AS g UNION
    SELECT k, random_geom_linestring(0, 100, 0, 100, 10, 5, 10)
    FROM generate_series(2, size) k;

The creation of a table `tbl_geom_polygon3D` containing random `geometry` 3D polygon values without holes, having between 5 and 10 vertices, where the x, y, and z coordinates are in the range [0, 100] and the maximum difference between consecutive coordinate values is 10 units in the underlying SRID is given next.

    CREATE TABLE tbl_geom_polygon3D AS
    SELECT 1 AS k, geometry 'polygon Z empty' AS g UNION
    SELECT k, random_geom_polygon3D(0, 100, 0, 100, 0, 100, 10, 5, 10)
    FROM generate_series(2, size) k;

The creation of a table `tbl_geom_multipoint` containing random `geometry` 2D multipoint values having between 5 and 10 points, where the x and y coordinates are in the range [0, 100] and the maximum difference between consecutive coordinate values is 10 units in the underlying SRID is given next.

    CREATE TABLE tbl_geom_multipoint AS
    SELECT 1 AS k, geometry 'multipoint empty' AS g UNION
    SELECT k, random_geom_multipoint(0, 100, 0, 100, 10, 5, 10)
    FROM generate_series(2, size) k;

The creation of a table `tbl_geog_multilinestring` containing random `geography` 2D multilinestring values having between 5 and 10 linestrings, each one having between 5 and 10 vertices, where the x and y coordinates are, respectively, in the ranges [-10, 32] and [35, 72], and the maximum difference between consecutive coordinate values is 10 is given next.

    CREATE TABLE tbl_geog_multilinestring AS
    SELECT 1 AS k, geography 'multilinestring empty' AS g UNION
    SELECT k, random_geog_multilinestring(-10, 32, 35, 72, 10, 5, 10, 5, 10)
    FROM generate_series(2, size) k;

The creation of a table `tbl_geometry3D` containing random `geometry` 3D values of various types is given next. This function requires that the tables for the various geometry types have been created previously.

    CREATE TABLE tbl_geometry3D (
      k serial PRIMARY KEY,
      g geometry);
    INSERT INTO tbl_geometry3D(g)
    (SELECT g FROM tbl_geom_point3D ORDER BY k LIMIT (size * 0.1)) UNION ALL
    (SELECT g FROM tbl_geom_linestring3D ORDER BY k LIMIT (size * 0.1)) UNION ALL
    (SELECT g FROM tbl_geom_polygon3D ORDER BY k LIMIT (size * 0.2)) UNION ALL
    (SELECT g FROM tbl_geom_multipoint3D ORDER BY k LIMIT (size * 0.2)) UNION ALL
    (SELECT g FROM tbl_geom_multilinestring3D ORDER BY k LIMIT (size * 0.2)) UNION ALL
    (SELECT g FROM tbl_geom_multipolygon3D ORDER BY k LIMIT (size * 0.2));

The creation of a table `tbl_tbool_inst` containing random `tbool` values of instant subtype where the timestamps are in the range [2001-01-01, 2001-12-31] is given next.

    CREATE TABLE tbl_tbool_inst AS
    /* Add perc NULL values */
    SELECT k, NULL AS inst
    FROM generate_series(1, perc) AS k UNION
    SELECT k, random_tbool_inst('2001-01-01', '2001-12-31')
    FROM generate_series(perc+1, size) k;
    /* Add perc duplicates */
    UPDATE tbl_tbool_inst t1
    SET inst = (SELECT inst FROM tbl_tbool_inst t2 WHERE t2.k = t1.k+perc)
    WHERE k in (SELECT i FROM generate_series(1 + 2*perc, 3*perc) i);
    /* Add perc rows with the same timestamp */
    UPDATE tbl_tbool_inst t1
    SET inst = (SELECT tboolinst(random_bool(), getTimestamp(inst))
      FROM tbl_tbool_inst t2 WHERE t2.k = t1.k+perc)
    WHERE k in (SELECT i FROM generate_series(1 + 4*perc, 5*perc) i);

As can be seen above, the table has a percentage of null values, of duplicates, and of rows with the same timestamp.

The creation of a table `tbl_tint_discseq` containing random `tint` values of sequence subtype and discrete interpolation having between 5 and 10 timestamps where the integer values are in the range [0, 100], the timestamps are in the range [2001-01-01, 2001-12-31], the maximum difference between two consecutive values is 10, and the maximum interval between two consecutive instants is 10 minutes is given next.

    CREATE TABLE tbl_tint_discseq AS
    /* Add perc NULL values */
    SELECT k, NULL AS ti
    FROM generate_series(1, perc) AS k UNION
    SELECT k, random_tint_discseq(0, 100, '2001-01-01', '2001-12-31', 10, 10, 5, 10) AS ti
    FROM generate_series(perc+1, size) k;
    /* Add perc duplicates */
    UPDATE tbl_tint_discseq t1
    SET ti = (SELECT ti FROM tbl_tint_discseq t2 WHERE t2.k = t1.k+perc)
    WHERE k in (SELECT i FROM generate_series(1 + 2*perc, 3*perc) i);
    /* Add perc rows with the same timestamp */
    UPDATE tbl_tint_discseq t1
    SET ti = (SELECT ti + random_int(1, 2) FROM tbl_tint_discseq t2 WHERE t2.k = t1.k+perc)
    WHERE k in (SELECT i FROM generate_series(1 + 4*perc, 5*perc) i);
    /* Add perc rows that meet */
    UPDATE tbl_tint_discseq t1
    SET ti = (SELECT shift(ti, endTimestamp(ti)-startTimestamp(ti))
      FROM tbl_tint_discseq t2 WHERE t2.k = t1.k+perc)
    WHERE t1.k in (SELECT i FROM generate_series(1 + 6*perc, 7*perc) i);
    /* Add perc rows that overlap */
    UPDATE tbl_tint_discseq t1
    SET ti = (SELECT shift(ti, date_trunc('minute',(endTimestamp(ti)-startTimestamp(ti))/2))
      FROM tbl_tint_discseq t2 WHERE t2.k = t1.k+2)
    WHERE t1.k in (SELECT i FROM generate_series(1 + 8*perc, 9*perc) i);

As can be seen above, the table has a percentage of null values, of duplicates, of rows with the same timestamp, of rows that meet, and of rows that overlap.

The creation of a table `tbl_tfloat_seq` containing random `tfloat` values of sequence subtype having between 5 and 10 timestamps where the `float` values are in the range [0, 100], the timestamps are in the range [2001-01-01, 2001-12-31], the maximum difference between two consecutive values is 10, and the maximum interval between two consecutive instants is 10 minutes is given next.

    CREATE TABLE tbl_tfloat_seq AS
    /* Add perc NULL values */
    SELECT k, NULL AS seq
    FROM generate_series(1, perc) AS k UNION
    SELECT k, random_tfloat_seq(0, 100, '2001-01-01', '2001-12-31', 10, 10, 5, 10) AS seq
    FROM generate_series(perc+1, size) k;
    /* Add perc duplicates */
    UPDATE tbl_tfloat_seq t1
    SET seq = (SELECT seq FROM tbl_tfloat_seq t2 WHERE t2.k = t1.k+perc)
    WHERE k in (SELECT i FROM generate_series(1 + 2*perc, 3*perc) i);
    /* Add perc tuples with the same timestamp */
    UPDATE tbl_tfloat_seq t1
    SET seq = (SELECT seq + random_int(1, 2) FROM tbl_tfloat_seq t2 WHERE t2.k = t1.k+perc)
    WHERE k in (SELECT i FROM generate_series(1 + 4*perc, 5*perc) i);
    /* Add perc tuples that meet */
    UPDATE tbl_tfloat_seq t1
    SET seq = (SELECT shift(seq, timespan(seq)) FROM tbl_tfloat_seq t2 WHERE t2.k = t1.k+perc)
    WHERE t1.k in (SELECT i FROM generate_series(1 + 6*perc, 7*perc) i);
    /* Add perc tuples that overlap */
    UPDATE tbl_tfloat_seq t1
    SET seq = (SELECT shift(seq, date_trunc('minute',timespan(seq)/2))
      FROM tbl_tfloat_seq t2 WHERE t2.k = t1.k+perc)
    WHERE t1.k in (SELECT i FROM generate_series(1 + 8*perc, 9*perc) i);

The creation of a table `tbl_ttext_seqset` containing random `ttext` values of sequence set subtype having between 5 and 10 sequences, each one having between 5 and 10 timestamps, where the text values have at most 10 characters, the timestamps are in the range [2001-01-01, 2001-12-31], and the maximum interval between two consecutive instants is 10 minutes is given next.

    CREATE TABLE tbl_ttext_seqset AS
    /* Add perc NULL values */
    SELECT k, NULL AS ts
    FROM generate_series(1, perc) AS k UNION
    SELECT k, random_ttext_seqset('2001-01-01', '2001-12-31', 10, 10, 5, 10, 5, 10) AS ts
    FROM generate_series(perc+1, size) AS k;
    /* Add perc duplicates */
    UPDATE tbl_ttext_seqset t1
    SET ts = (SELECT ts FROM tbl_ttext_seqset t2 WHERE t2.k = t1.k+perc)
    WHERE k in (SELECT i FROM generate_series(1 + 2*perc, 3*perc) i);
    /* Add perc tuples with the same timestamp */
    UPDATE tbl_ttext_seqset t1
    SET ts = (SELECT ts || text 'A' FROM tbl_ttext_seqset t2 WHERE t2.k = t1.k+perc)
    WHERE k in (SELECT i FROM generate_series(1 + 4*perc, 5*perc) i);
    /* Add perc tuples that meet */
    UPDATE tbl_ttext_seqset t1
    SET ts = (SELECT shift(ts, timespan(ts)) FROM tbl_ttext_seqset t2 WHERE t2.k = t1.k+perc)
    WHERE t1.k in (SELECT i FROM generate_series(1 + 6*perc, 7*perc) i);
    /* Add perc tuples that overlap */
    UPDATE tbl_ttext_seqset t1
    SET ts = (SELECT shift(ts, date_trunc('minute', timespan(ts)/2))
      FROM tbl_ttext_seqset t2 WHERE t2.k = t1.k+perc)
    WHERE t1.k in (SELECT i FROM generate_series(1 + 8*perc, 9*perc) i);

The creation of a table `tbl_tgeompoint_discseq` containing random `tgeompoint` 2D values of sequence subtype and discrete interpolation having between 5 and 10 instants, where the x and y coordinates are in the range [0, 100] and in SRID 3812, the timestamps are in the range [2001-01-01, 2001-12-31], the maximum difference between successive coordinates is at most 10 units in the underlying SRID, and the maximum interval between two consecutive instants is 10 minutes is given next.

    CREATE TABLE tbl_tgeompoint_discseq AS
    SELECT k, random_tgeompoint_discseq(0, 100, 0, 100, '2001-01-01', '2001-12-31',
      10, 10, 5, 10, 3812) AS ti
    FROM generate_series(1, size) k;
    /* Add perc duplicates */
    UPDATE tbl_tgeompoint_discseq t1
    SET ti = (SELECT ti FROM tbl_tgeompoint_discseq t2 WHERE t2.k = t1.k+perc)
    WHERE k IN (SELECT i FROM generate_series(1, perc) i);
    /* Add perc tuples with the same timestamp */
    UPDATE tbl_tgeompoint_discseq t1
    SET ti = (SELECT round(ti,6) FROM tbl_tgeompoint_discseq t2 WHERE t2.k = t1.k+perc)
    WHERE k IN (SELECT i FROM generate_series(1 + 2*perc, 3*perc) i);
    /* Add perc tuples that meet */
    UPDATE tbl_tgeompoint_discseq t1
    SET ti = (SELECT shift(ti, endTimestamp(ti)-startTimestamp(ti))
      FROM tbl_tgeompoint_discseq t2 WHERE t2.k = t1.k+perc)
    WHERE t1.k IN (SELECT i FROM generate_series(1 + 4*perc, 5*perc) i);
    /* Add perc tuples that overlap */
    UPDATE tbl_tgeompoint_discseq t1
    SET ti = (SELECT shift(ti, date_trunc('minute',(endTimestamp(ti)-startTimestamp(ti))/2))
      FROM tbl_tgeompoint_discseq t2 WHERE t2.k = t1.k+2)
    WHERE t1.k IN (SELECT i FROM generate_series(1 + 6*perc, 7*perc) i);

Finally, the creation of a table `tbl_tgeompoint3D_seqset` containing random `tgeompoint` 3D values of sequence set subtype having between 5 and 10 sequences, each one having between 5 and 10 timestamps, where the x, y, and z coordinates are in the range [0, 100] and in SRID 3812, the timestamps are in the range [2001-01-01, 2001-12-31], the maximum difference between successive coordinates is at most 10 units in the underlying SRID, and the maximum interval between two consecutive instants is 10 minutes is given next.

    DROP TABLE IF EXISTS tbl_tgeompoint3D_seqset;
    CREATE TABLE tbl_tgeompoint3D_seqset AS
    SELECT k, random_tgeompoint3D_seqset(0, 100, 0, 100, 0, 100, '2001-01-01', '2001-12-31',
      10, 10, 5, 10, 5, 10, 3812) AS ts
    FROM generate_series(1, size) AS k;
    /* Add perc duplicates */
    UPDATE tbl_tgeompoint3D_seqset t1
    SET ts = (SELECT ts FROM tbl_tgeompoint3D_seqset t2 WHERE t2.k = t1.k+perc)
    WHERE k IN (SELECT i FROM generate_series(1, perc) i);
    /* Add perc tuples with the same timestamp */
    UPDATE tbl_tgeompoint3D_seqset t1
    SET ts = (SELECT round(ts,3) FROM tbl_tgeompoint3D_seqset t2 WHERE t2.k = t1.k+perc)
    WHERE k IN (SELECT i FROM generate_series(1 + 2*perc, 3*perc) i);
    /* Add perc tuples that meet */
    UPDATE tbl_tgeompoint3D_seqset t1
    SET ts = (SELECT shift(ts, timespan(ts)) FROM tbl_tgeompoint3D_seqset t2 WHERE t2.k = t1.k+perc)
    WHERE t1.k IN (SELECT i FROM generate_series(1 + 4*perc, 5*perc) i);
    /* Add perc tuples that overlap */
    UPDATE tbl_tgeompoint3D_seqset t1
    SET ts = (SELECT shift(ts, date_trunc('minute', timespan(ts)/2))
      FROM tbl_tgeompoint3D_seqset t2 WHERE t2.k = t1.k+perc)
    WHERE t1.k IN (SELECT i FROM generate_series(1 + 6*perc, 7*perc) i);

## Generator for Temporal Network Point Types

- `random_fraction`: Generate a random fraction in the range [0,1]

- `random_npoint`: Generate a random network point

- `random_nsegment`: Generate a random network segment

- `random_tnpoint_inst`: Generate a random temporal network point of instant subtype

- `random_tnpoint_discseq`: Generate a random temporal network point of sequence subtype and discrete interpolation

- `random_tnpoint_seq`: Generate a random temporal network point of sequence subtype and linear or step interpolation

- `random_tnpoint_seqset`: Generate a random temporal network point of sequence set subtype

The file `/datagen/npoint/create_test_tables_tnpoint.sql` provide usage examples for the functions generating random values listed above.