| 1 | #ifndef _NUMrandom_h_ |
| 2 | #define _NUMrandom_h_ |
| 3 | /* NUMrandom.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2018,2020,2025,2026 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | /********** Random numbers **********/ |
| 22 | |
| 23 | void NUMrandom_initializeSafelyAndUnpredictably (); |
| 24 | void NUMrandom_initializeWithSeedUnsafelyButPredictably (uint64 seed); |
| 25 | |
| 26 | constexpr integer NUMrandom_maximumNumberOfParallelThreads = 400; |
| 27 | // The number of random channels will be three more than this: |
| 28 | // thread 0: the thread in which Praat commands and Praat scripts run |
| 29 | // threads 1 through 399 or 400: extra threads for parallellization in analyses (the master thread stays 0) |
| 30 | // thread 401: user-interface randomization (not really a thread) |
| 31 | // thread 402: spare "thread" |
| 32 | constexpr integer NUMrandom_numberOfChannels = NUMrandom_maximumNumberOfParallelThreads + 3; |
| 33 | |
| 34 | void NUMrandom_setChannel (integer channelNumber); |
| 35 | // To be set by each parallel thread to a value between 0 and NUMrandom_numberOfChannels - 1. |
| 36 | void NUMrandom_useUserInterfaceChannel (); |
| 37 | // Sets the channel number in the current thread to 401 |
| 38 | void NUMrandom_useSpareChannel (); |
| 39 | // Sets the channel number in the current thread to 402 |
| 40 | integer NUMrandom_getChannel (); |
| 41 | // Returns the random channel associated with the current thread (rarely useful, but who knows); |
| 42 | // only to be called after one of the three channel-settings functions has been called. |
| 43 | |
| 44 | double NUMrandomFraction (); |
| 45 | |
| 46 | double NUMrandomUniform (double lowest, double highest); |
| 47 | |
| 48 | integer NUMrandomInteger (integer lowest, integer highest); |
| 49 | |
| 50 | bool NUMrandomBernoulli (double probability); |
| 51 | double NUMrandomBernoulli_real (double probability); |
| 52 | |
| 53 | double NUMrandomImax (constVECVU const& vec); |
| 54 | |
| 55 | double NUMrandomGauss (double mean, double standardDeviation); |
| 56 | |
| 57 | double NUMrandomPoisson (double mean); |
| 58 | |
| 59 | uint32 NUMhashString (conststring32 string); |
| 60 | |
| 61 | /* End of file NUMrandom.h */ |
| 62 | #endif |