How to give a global a random number excluding 0 - random

I am quite new to Netlogo and I am experiencing the following problem. I want to give a variable a random number between 1 and 10, so without 0. Using the following code: set random 10, netlogo will also pick 0 as a possibility. Is there any way to avoid this? Random-float works, but this does not select whole numbers. Thanks in advance for any help!
Max

Use random 10 + 1. random 10 generates a number from 0 to 9, adding 1 to it gives a range of 1 to 10.

Related

How can I make a complex ifelse algorithm which comprehend dates and time?

I have got a data-management problem. I have a database where "EDSS.1","EDSS.2",... represent a numeric variable, scaled from 0 to 10 (0.5 scale), where higher number stand for higher disability. For each EDSS variable, I have a "VISITDATE.1", "VISITDATE.2",...
EDSS
VISITDATE
Now I am interested in assessing the CONFIRMED DISABILITY PROGRESSION (CDP), which is an increased i 1 poin on the EDSS. To make things more difficult, this increment need to be confirmed in the subsequent visit (e.g. EDSS.3) which has to be >= 6 months (which is, VISITDATE.3 - VISITDATE.2 > 6 months.
To do so, I am creating a nested ifelse statement, as showed below.
prova <- prova %>% mutate(
CDP = ifelse(EDSS.2 > EDSS.1 & EDSS.3>=EDSS.2 & difftime(VISITDATE.3,VISITDATE.2,
units = "weeks") > 48,
print(ymd(VISITDATE.2)),0))
However, I am facing the following main problems:
How can I print the VISIT.DATE of my interest instead of 1 or 0?
How can I shift my code to the EDSS.2,EDSS.3, and so on? I am interested in finding all the confirmed disability progressions (CDPs).
Many thanks to everyone who find the time to answer me.

Visual Foxpro 9 Odd behaviour with large numeric values

Can someone please explain this behaviour and suggest a way around it?
In the command window on VFP 9.
Test 1
a = 7003602346555440
? a
Displays correct value.
Test 2
a = 7003602346555438
? a
Still fine.
Test 3
a = 7003602346555439
? a
Displays incorrect value of 7003602346555440
Test 4
? a=7003602346555439
Returns .T. as you'd expect.
Test 5
? VAL(7003602346555439)
Displays incorrect value of 7003602346555440
Clearly something odd going on with converting the numeric into the textual representation for display, but can anyone suggest a way to avoid this and ensure I always get the correct text version of the numeric?
Source from this article
SUMMARY
Visual FoxPro is documented as having 16 digits of precision. This is an
approximation: the actual maximum exactly representable number is
9007199254740992 (2^53).
MORE INFORMATION
Floating point numbers are stored in 8-byte or 64-bit representations. There are
12 bits of overhead, leaving 52 bits to store the number. There is one more
implied bit that gives you 2^53 as the maximum. The maximum number that can be
stored by Visual FoxPro is 2^1023. The highest power of two that is printed out
exactly using the ? command with the default setting of SET DECIMALS TO 2 is
2^43.
The following code demonstrates this:
SET DECIMALS TO 2
? 2^43 && All digits displayed
? 2^44 && Scientific notation
SET DECIMALS TO 5
? 2^53 && Maximum exact number
? 2^53 - 1 && Correct result
? 2^53 + 1 && Incorrect result: rounded in floating point
? 2^1023 && Cannot display: *'s will be printed
? 2^1022 && Can display
Even though the documentation says that val() will round up after 16 digits, it often rounds up at 16 and above. The example you are showing uses 16 digits and that is causing val() to round up.

Binary Search with multiple midpoints confusion

I'm reviewing for my midterm and this specific question is causing me some issues.
This is the following array to perform the binary search:
the value I want to search for is 150.
To start off, I take the first element which is 0, and the last element which is 15.
(start + end) / 2,
(0 + 15) / 2 = 7
The value at the array of 7 is 90.
90 < 150, so the value is contained in the right side of the array.
The array now looks like this:
Continuing with the same logic
(start + end) / 2
(8 + 15) / 2 = 11.
However, according to the professor I should be at the value 12 here. I'm not sure what i am doing wrong. Any help would be appreciated.
The algorithms were written even before the computers were invented.
Computers are simply a tool or a device which implements the algorithm in an efficient manner which is why it is fast.
The binary search which you are performing here is relevant to computers as the array are indexed from 0 (counting usually starts from 0 in computers), that is why you are getting 11 which is correct in point of computers.
But for the humans counting starts from 1 and the so the result according to professor is 12.
While writing algorithms we write in according to the perception of the human and we twist it a little to implement in our machine.

Create a mark function from a normal law

I'm working on an android application and at some point, I retrieve a value contained between -100 and 100 which follow a normal law (I don't have the parameters of this law).
I would like to create a function which returns me a mark on 20 but to avoid to have all marks between 8 and 12, I would like to "stretch" values around 0.
For example, a variation of 1 around the 0 will give me a 0.5 point of difference in the mark, and a 1 point variation around the 100 will give me a 0.01 point of difference in the mark.
Is there any algorithm/function/trick that will gave me this possibility ? Which could be the conditions or requirement ? Is there any library available that will give me this possibility ? (I search but didn't found...)
Thank you !

Retrieve multiple information by a single number?

I was wondering how they did come up with the way of setting permissions using chmod by just using numbers. For example:
1 is for execute
2 is for write
4 is for read
Any sum of those give a unique permission:
2+4 = 6 lets you write and read.
1+4 = 5 lets you execute and read
1+2+4 = 7 lets you execute, read and write
Is there an algorithm to this? Say for example I have 10 items and I want to give to a person a number and by just that number the person can tell which items I have chosen.
Binary system. I.e. you represent 1, 2, 4, 8, 16, and so on with a 0-or-1-digit each. The last digit stands for 2^0=1, the second-last digit stands for 2^1=2, the next digit for 2^2=4, the next for 2^3=8 and so on.
Now, you associate an action (read/ex/write) with each digit.
A (more or less) surprising fact is the following: If you don't have just two options (i.e. if you do not just have true or false), but if you have more, you can adapt this pattern to the ternary system. Moreover, you can adapt this pattern for any base. The human system works for base 10.

Resources