ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pnint.m File Reference

Go to the source code of this file.

Functions

function pnint (in val)
 Generate and return the probabilistically-rounded to the nearest integer value of the input real number. More...
 

Function Documentation

◆ pnint()

function pnint ( in  val)

Generate and return the probabilistically-rounded to the nearest integer value of the input real number.

Unlike the intrinsic Fortran nint() function, the procedures of this generic interface round the input real number to the nearest integer value probabilistically.
The closer the input val is to its nint(val) result, the more likely it will be rounded to it.
See below for example usage.

Parameters
[in]val: The input scalar or array of the same rank as other array-like arguments, containing the number to be rounded probabilistically.
Returns
whole : The output scalar or array of the same rank and shape as the input arguments, of default integer kind, containing the probabilistically-rounded input value to the nearest integer.


Possible calling interfaces

whole = pm.math.pnint(val);


Example usage

1cd(fileparts(mfilename('fullpath'))); % Change working directory to source code directory.
2addpath('../../../'); % Add the ParaMonte library root directory to the search path.
3
4pm.matlab.show()
5pm.matlab.show("val = repmat([5., 5.2, 5.5, 5.8, 6.], 20, 1);")
6 val = repmat([5., 5.2, 5.5, 5.8, 6.], 20, 1);
7pm.matlab.show("val")
8pm.matlab.show( val )
9pm.matlab.show("pm.math.pnint(val)")
10pm.matlab.show( pm.math.pnint(val) )
function root()
Return a scalar MATLAB string containing the root directory of the ParaMonte library package.

Example output
1
2val = repmat([5., 5.2, 5.5, 5.8, 6.], 20, 1);
3val
4val
5 Columns 1 through 3
6 5.000000000000000 5.200000000000000 5.500000000000000
7 5.000000000000000 5.200000000000000 5.500000000000000
8 5.000000000000000 5.200000000000000 5.500000000000000
9 5.000000000000000 5.200000000000000 5.500000000000000
10 5.000000000000000 5.200000000000000 5.500000000000000
11 5.000000000000000 5.200000000000000 5.500000000000000
12 5.000000000000000 5.200000000000000 5.500000000000000
13 5.000000000000000 5.200000000000000 5.500000000000000
14 5.000000000000000 5.200000000000000 5.500000000000000
15 5.000000000000000 5.200000000000000 5.500000000000000
16 5.000000000000000 5.200000000000000 5.500000000000000
17 5.000000000000000 5.200000000000000 5.500000000000000
18 5.000000000000000 5.200000000000000 5.500000000000000
19 5.000000000000000 5.200000000000000 5.500000000000000
20 5.000000000000000 5.200000000000000 5.500000000000000
21 5.000000000000000 5.200000000000000 5.500000000000000
22 5.000000000000000 5.200000000000000 5.500000000000000
23 5.000000000000000 5.200000000000000 5.500000000000000
24 5.000000000000000 5.200000000000000 5.500000000000000
25 5.000000000000000 5.200000000000000 5.500000000000000
26 Columns 4 through 5
27 5.800000000000000 6.000000000000000
28 5.800000000000000 6.000000000000000
29 5.800000000000000 6.000000000000000
30 5.800000000000000 6.000000000000000
31 5.800000000000000 6.000000000000000
32 5.800000000000000 6.000000000000000
33 5.800000000000000 6.000000000000000
34 5.800000000000000 6.000000000000000
35 5.800000000000000 6.000000000000000
36 5.800000000000000 6.000000000000000
37 5.800000000000000 6.000000000000000
38 5.800000000000000 6.000000000000000
39 5.800000000000000 6.000000000000000
40 5.800000000000000 6.000000000000000
41 5.800000000000000 6.000000000000000
42 5.800000000000000 6.000000000000000
43 5.800000000000000 6.000000000000000
44 5.800000000000000 6.000000000000000
45 5.800000000000000 6.000000000000000
46 5.800000000000000 6.000000000000000
47pm.math.pnint(val)
48 5 5 6 6 6
49 5 6 6 6 6
50 5 5 5 6 6
51 5 5 6 6 6
52 5 5 6 6 6
53 5 6 5 6 6
54 5 5 6 6 6
55 5 5 6 6 6
56 5 5 6 6 6
57 5 5 6 6 6
58 5 5 6 6 6
59 5 5 5 6 6
60 5 5 5 6 6
61 5 5 5 6 6
62 5 5 6 6 6
63 5 5 6 5 6
64 5 5 6 6 6
65 5 6 5 6 6
66 5 6 6 6 6
67 5 5 6 6 6


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, April 23, 2017, 1:36 AM, Institute for Computational Engineering and Sciences (ICES), University of Texas at Austin