search for: randint

Displaying 12 results from an estimated 12 matches for "randint".

2006 Aug 04
3
Building a random walk vector
I'm studying R in my free time. I want to build a vector where each element is equal to the element before it in the sequence plus some random tweak. In python, I would write: vec = [100] * 50 # make a 50-element list with each element set to 100 from random import randint for i, v in enumerate(vec): if i is not 0: # if we're not on the first element vec[i] = vec[i-1] + randint(-2, 2) I suspect R has some fancier way of doing this. How to? TIA -- A better way of running series of SAS programs: http://overlook.homelinux.net/wilsonwiki/SasAndMakef...
2018 Jul 22
2
R History: Why is there no importFrom() function?
...decision for the R language. Programs or analyses written in R typically use library() to pull in functions from non-core packages. This differs markedly from most languages*, which usually offer some way to selectively import symbols. For example, in Python you'd see "from random import randint", and so on. Within R packages, the NAMESPACE file provides this exact functionality with the importFrom() directive, but the R language itself does not expose this as a function for regular users. I know that R did not have namespaces for some of its early existence, but I'm curious as...
2015 Jan 22
2
[LLVMdev] access IntegerType::getSignBit from Type *
...tract the IntegerType.getSignBit? If pType isIntegerType, I need to know if it is signed or unsigned... How to achieve this? Thx Alex llvm::Type * getRandomValid_IntegerType(llvm::LLVMContext &C) { using namespace llvm; //--- determine num of bits between allowed bits int rI=randInt(IntegerType::MIN_INT_BITS,IntegerType::MAX_INT_BITS); return IntegerType::get(C, rI); } llvm::Type * pType=getRandomValid_IntegerType(llvm::LLVMContext &C); if(pType.isIntegerTy) { pType->getIntegerBitWidth(); // ok pType->HOWTOGET_SIGN_INFO; //? }
2006 Nov 21
2
Handle Options Method
Hi, I have an Alteon in test (a sip/rtp load balancer). This Alteon sends to the asterisk box a "SIP OPTIONS" to know if asterisk is alive. However, asterisk sends me a 404 message and not a response like, for example, a Thomson (200 + SDP) I wrote a very little script (you can find it at the end of the email) to send an Options message to asterisk/phones to try. It works
2012 Jan 28
2
Need very fast application of 'diff' - ideas?
...the data between languages could kill any improvements. I don't have much experience integrating other languages, so I'm hoping the community has some ideas about how to approach this particular problem... Many thanks, Kevin In iPython: In [3]: import numpy as np In [4]: arr = np.random.randint(0, 1000, (10000000,1)).astype("int16") In [5]: arr1 = arr[1:].view() In [6]: timeit arr2 = arr1 - arr[:-1] 10 loops, best of 3: 20.1 ms per loop In Clojure: (defn subtract-lag [n] (let [v (take n (repeatedly rand))] (time (dorun (map - v (cons 0 v)))))) [[alternative HTML...
2018 Sep 26
1
Re: [PATCH v2 3/3] v2v: -o rhv-upload: Add a test.
On Thursday, 20 September 2018 10:50:14 CEST Richard W.M. Jones wrote: > +# Choose a random port number in range [50000,59999] > +imageio_port = random.randint(50000,60000) > + > [...] > + > +def server(): > + server_address = ("", imageio_port) > + httpd = HTTPServer(server_address, RequestHandler) > + httpd.serve_forever() The random port can be chosen directly by the OS, using the special port 0: >>>...
2007 Jan 05
1
help for memory problem with 64-bit machines
...The Fortran subroutine where the crash occurs has variable-length arrays. Could there be a problem with this (the user who spotted the problem is running the gfortran gcc compiler - I presume r-devel Linux x86_64 does too)? 3) the guilty routine ("randsk1") calls a second routine ("randint") which, in turn, calls R's Random Number Generator. Can the problem arise in the Fortran/R interface? As I said, any idea of what the problem may be, or where I can look for help, would be much appreciated. In despair, but with best regards, Jorge Cadima ----------------------------...
2018 Sep 20
7
[PATCH v2 0/3] v2v: -o rhv-upload: Add a test.
v1 was here: https://www.redhat.com/archives/libguestfs/2018-September/msg00121.html v2: - Rewrote patch 2 from scratch so it incorporates Nir's suggestions. - Add fake module to EXTRA_DIST. - Retested. Unfortunately I am no longer able to test the ordinary conversion path because ovirtsdk4 is incompatible with Fedora 29 / Python 3.7:
2018 Sep 20
0
[PATCH v2 3/3] v2v: -o rhv-upload: Add a test.
...rch=None): + return [] + +# Create a background thread running a web server which is +# simulating the imageio server. + +from http.server import HTTPServer, BaseHTTPRequestHandler +import random +import threading + +# Choose a random port number in range [50000,59999] +imageio_port = random.randint(50000,60000) + +class RequestHandler(BaseHTTPRequestHandler): + def do_OPTIONS(self): + self.send_response(200) + self.send_header("Content-type", "application/json; charset=UTF-8") + self.end_headers() + # Advertize only zero support. + sel...
2018 Sep 19
4
[PATCH 0/3] v2v: -o rhv-upload: Add a test.
This adds a test of -o rhv-upload. Obviously for an upstream test we cannot require a working oVirt server. This test works by faking the ovirtsdk4 Python module, setting PYTHONPATH so that the fake module is picked up instead of the real module (if installed). However it's more complex than that because the nbdkit plugin also expects to talk to a working imageio HTTPS server. Therefore
2018 Oct 09
2
Re: [PATCH v2 3/3] v2v: -o rhv-upload: Add a test.
...dule, since it is not part of the SDK, and may be replaced by real imageio server later. > + > +from http.server import HTTPServer, BaseHTTPRequestHandler > +import random > +import threading > + > +# Choose a random port number in range [50000,59999] > +imageio_port = random.randint(50000,60000) > + > +class RequestHandler(BaseHTTPRequestHandler): > This request handler is using HTTP/1.0, and will close the connection after every request. This is not a good implementation of the imageio server, and also hides bugs in this code. Should be fixed by adding: protoc...
2016 May 04
9
[PATCH 0/8] python: PEP 8 fixes
Hi, this series cleans up the Python sources, either static or generated, including also tests, to make them PEP 8 compliant; see https://www.python.org/dev/peps/pep-0008/ and tools like pep8. Almost all the issues reported by pep8 are fixed, reducing the issues from 3818 to 7. The changes should have no effect on the actual code, while it will help Python users with consistency with other