/*
 *  test_rdv_discreteness.sli
 *
 *  This file is part of NEST.
 *
 *  Copyright (C) 2004 The NEST Initiative
 *
 *  NEST is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  NEST is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with NEST.  If not, see <http://www.gnu.org/licenses/>.
 *
 */


/* BeginDocumentation
Name: testsuite::test_rdv_discreteness - test discreteness of random distributions

Synopsis: (test_rdv_discreteness.sli) run -> dies if assertion fails

Description:
Test that discrete random distributions actually return integer values for
Random and RandomArray and continuous random distributions return double values
for Random and RandomArray.

Author: Ippen
FirstVersion: 160304
*/

(unittest) run
/unittest using

rngdict /gsl_knuthran known { /gsl_knuthran } { /knuthlfg } ifelse
rngdict exch get 123456789 CreateRNG /rng Set

% check all random deviations
rdevdict keys
{
  /rdv_name Set

  rng rdevdict rdv_name get CreateRDV /rdv Set

  rdv GetStatus /is_discrete get
  {
    % check discrete RDV
    0 1 10 % try 10 random numbers
    {
      {
        rdv Random IntegerQ exch ;
      } assert_or_die
    } for
    {
      rdv 10 RandomArray 
      true exch { IntegerQ exch ; and } Fold
    } assert_or_die
  }
  {
    % check continuous RDV
    0 1 10 % try 10 random numbers
    {
      true {
        rdv Random DoubleQ exch ;
      } assert_or_die
    } for
    {
      rdv 10 RandomArray 
      true exch { DoubleQ exch ; and } Fold
    } assert_or_die
  } ifelse
} forall
