How to generate a random path on a 2D grid

I want to create a random path in a 2D grid from a starting point in the bottom row and from an end point to the top of the row. I do not want the shortest path, or even the longest. Just a random path that can go up, down, left and right.

I have been researching this issue for days and can not find anything that can help solve the problem. I have read this question. This is the easiest way to generate a random path, but the answer provided does not allow the path back.

Some solutions I've thought of

1. On each line, select a random point, then go to each of these points. This does not allow to go back because I would continue to climb the rows.
2. Start at the starting point, select a random point, and so on until I reach the goal. It does not work because I can end up trapping and stalling.

How can I achieve this goal?

About the independence of random variables

Let $$xi_1$$, $$xi_2$$ are independent and have a normal standard distribution. How to show that $$xi ^ 2_1 + xi ^ 2_2$$ and $$frac { xi_1} { sqrt { xi ^ 2_1 + xi ^ 2_2}}$$ are independent?

algorithms – Simulation of a probability of 1 in 2 ^ N with less than N random bits

Suppose I have to simulate the following discrete distribution:

$$P (X = k) = begin {cases} frac {1} {2 ^ N}, & text {if k = 1 } \ 1 – frac {1} {2 ^ N}, & text {if k = 0 } end {cases}$$

The most obvious way is to draw $$N$$ random bits and check if all are equal to 0 (or 1). However, the theory of information says

begin {align} S & = – Sigma_ {i} P_i log {P_i} \ & = – frac {1} {2 ^ N} log { frac {1} {2 ^ N}} – left (1 – frac {1} {2 ^ N} right) log { left (1 – frac {1} {2 ^ N} right)} \ & = frac {1} {2 ^ N} log {2 ^ N} + left (1 – frac {1} {2 ^ N} right) log { frac {2 ^ N} {2 ^ N – 1}} \ & rightarrow 0 end {align}

So, the minimum number of random bits actually required decreases as $$N$$ go big. How is it possible?

Please assume we are working on a computer where bits are your only source of randomness, so you can not just throw a skewed piece.

Draw a complete graph with vertices placed at random positions?

Thank you for your contribution to Mathematica Stack Exchange!

• Please make sure to respond to the question. Provide details and share your research!

But to avoid

• Make statements based on opinions; save them with references or personal experience.

Use MathJax to format equations. MathJax reference.

javascript – Random in the return of a function

////////////////////////////////////////////////// //////// ///////////////////////
DOSSIER 1
////////////////////////////////////////////////// //////// ///////////////////////
pizzas const = {p: "pineapple", v: "vegetable", t: "veal", s: "salmon"};

leave faq =
[
[ // 0
// preguntas
[ "¿Qué te gusta más?",
"¿Qué pizza prefieres?",
"¿333333?",
"¿444444?"
],
(p) => {
if (p) {
return ["Me gusta mucho la pizza de " + pizzas[p],
"I'm crazy about pizzas" + pizzas[p],
"I have a passion for pizza" + pizzas[p]];
} else {
return ["Me gustan todas por igual.",
"No sabria decirte"];
}
}
],
[ // 1
// preguntas
[ "¿Hay algo que no te guste?",
"¿Qué pizzas le tienes grima?",
"¿Qué pizza no te gusta?",
"¿Qué pizza odias?"
],
(p) => {
if (p) {
"I hate pizza" + pizzas[p],
"Pizzas of" + pizzas[p] + "they are disgusting"];
} else {
return ["Me gustan todas por igual.",
"No sabria decirte"];
}
}
]]////////////////////////////////////////////////// //////// ///////////////////////
FILE 2
////////////////////////////////////////////////// //////// ///////////////////////

// form 1 using a class
class Faq {
constructor (faq) {
this.faq = faq.map (function (index, elem) {
back {
used: false,
preg: index[0][Mathfloor(Mathrandom()*index[Mathfloor(Mathrandom()*index[Mathfloor(Mathrandom()*index[Mathfloor(Mathrandom()*index[0].length)],
resp: index[1] // return an array but I only want a random choice
}
});
return this.faq;
}
}

// form 2 with a function
faq2 = function (faq) {
let f = faq.map (function (index, elem) {
back {
used: false,
preg: index[0][Mathfloor(Mathrandom()*index[Mathfloor(Mathrandom()*index[Mathfloor(Mathrandom()*index[Mathfloor(Mathrandom()*index[0].length)],
resp: index[1] // return an array but I only want a random choice
}
});
returns f;
}

// use
Let f1 = new Faq (faq);
Let f2 = faq2 (faq);
console.log ("question like:", f1[0].preg);
console.log ("do not like:", f1[0].resp (& # 39;));
console.log ("question like:", f2[0].preg);
console.log ("do not like:", f2[0].resp (& # 39;));

html5 – systematic random sampling in php

I send messages to Gmail accounts randomly selected in a file. This file contains the total number of accounts belonging to the target population. I want to select them using a systematic random sampling, that is to say by selecting the elements according to a random starting point, but respecting a periodic interval thereafter. All recommendations are welcome.

unit – create a random game of 7 cards each time they are all used?

It turns out that this week I was showing this method to my mechanics students of the game. 🙂

One of my favorite methods for working with a deck is to use an online version of a Fisher-Yates shuffle (also called Knuth shuffle).

IEnumerator ShuffleBag(params T[] articles) {
int remaining = items.Length;

while (true) {
// Choose a random object from what's left of our deck.
// (that is, the entries 0 ... remaining-1)
int drawIndex = Random.Range (0, remaining);
T drawnItem = elements[drawIndex];

// Removes the element from the platform by swapping it at the end.
remaining--;
goods[drawIndex] = articles[remaining];
goods[remaining] = drawnItem;

// Give the drawn element as our new .current element,
// and wait until we are asked to draw again.
yield return drawItem;

// If we have more cards when we ask for a new one,
// rework the scraps to make a new deck.
if (remaining == 0)
remaining = items.Length;
}
}


You can configure it as follows:

var bag = ShuffleBag (
Tetromino.I,
Tetromino.O,
Tetromino.T,
Tetromino.J,
Tetromino.L,
Tetromino.S,
Tetromino.Z
)


Then draw a new tetromino from the bag as follows:

bag.MoveNext ();
var tetromino = bag.current;


A new tetromino will always be ready: the bag will automatically put back the rejects as soon as it is empty and will distribute them in a new random order.

performance – Generate a random number from a binomial distribution

In my Monte Carlo simulation application, the key is to generate a random number from a binomial distribution with the parameters n = size and p = 0.5. Here is my current implementation

#understand
#understand
#understand

int64_t rbinom (size int64_t) {
if (! size) {
returns 0;
}

int64_t result = 0;
while (size> = 64) {
uint64_t random64;
while (! _rdrand64_step (& random64)) {
fprintf (stderr, "HW_RND_GEN not ready  n");
}
result + = _popcnt64 (random64);
size - = 64;
}

uint64_t random64;
while (! _rdrand64_step (& random64)) {
fprintf (stderr, "HW_RND_GEN not ready  n");
}
result + = _popcnt64 (random64 & ~ (UINT64_MAX << size));

return the result;
}


However, the result of the comparative analysis terrifies me:

I spend 99.68% of the run time on this function! How can I optimize it?

The result does not need to be cryptographically secure, as long as it is sufficient for Monte Carlo simulations.

data – random but consistent datasets

I have limited access to real data and I need some data for rapid prototyping. One way to get it is to generate it randomly. And it works well for simple datasets. But once a dataset has internal interdependencies that need to be checked and remain consistent, everything turns south. I am sure I am not the first to raise this issue. So, what is my best action plan (algorithms, frameworks, methodologies) to generate coherent but random datasets?

features – Random integers – Mathematica Stack Exchange

Thank you for your contribution to Mathematica Stack Exchange!

• Please make sure to respond to the question. Provide details and share your research!

But to avoid