## Six people, including Alice, Bob, and Connie, form a queue in random order. What is the probability when Bob is between Alice and Connie?

I figured out several patterns of queues like this:

$$ABC•••$$
$$A•BC••$$
$$AB•C••$$
$$AB••C•$$
$$AB•••C$$

Am I coming through the right way or not?
Can anyone give me some hints, please?

## probability theory – Sure vs almost sure convergence for a simple random variable

I thought I totally got it until I faced a simple problem and realized I’m getting a contradiction. For a simple rv defined on Lebesgue measure $$(Omega, mathcal{F}, mu)$$ on $$(0,1)$$:
$$X_n (omega) = bigg{ begin{array}{;r} 1 & text{if } omega in (0, frac{1}{n})\ 0& otherwise end{array}$$
the limit is $$X(omega)=0 forall omega in Omega$$. If I fix $$omega$$, then $$|X_{n geq frac{1}{omega}} – X(omega)|=0$$, and this is true $$forall Omega$$, so $$lim_n X_n(omega) = X(omega) forall Omega.$$, i.e. sure convergence. At the same time, to get convergence almost surely, I find
$$mu({omega:|X_n(omega) neq X(omega)|}) = frac{1}{n} Rightarrowsum_nmu(X_n (omega) neq X(omega)) = sum_n frac{1}{n} to infty$$
Therefore, $$X_n (omega) notto X(omega)$$ a.s., because it is $$=1$$ i.o. w.p. $$1$$ (it’s easy to see it converges in probability because $$frac{1}{n} to_n 0$$).

So I’d be grateful if someone could point out the flaw in my my logic.

## charging – Bootloop and random restart issues in android (Gionee A1 plus)

My Gionee A1 plus started acting strange a month ago. It would often restart whenever I received any SMS notification and then boot up just fine. I tried using an earphone and keeping the phone in silent mode, as reducing the notification sound levels didn’t help. This fixed the problem for a few weeks until 2 days ago while using my camera, it suddenly decided to restart but got stuck in a bootloop(the boot logo kept popping up and disappearing again and again). I managed to turn it off by plugging it to a charger where it went to charging mode.

After a bit of research, I entered the stock “Android recovery mode” and cleared the /cache partition but that did not fix the issue. I panicked as I did not have a twrp or any other recovery tool installed. I didn’t even have USB debugging enabled. However, after a bit more strolling I found that fastboot could detect my device(after rebooting to bootloader) and then ran the command `fastboot continue` and my phone booted up alright. But now my phone can’t use the “Ultrafast charge mode” which makes the charging process 5 times longer and the battery drains really quick. What’s more the phone restarting by itself has become often(I can’t even use my camera) and its always the bootloop. I have to use fastboot to boot in again.

I created a backup of my data and then did a factory reset on the device to no use.

Do I need to flash a stock ROM to my device or am I missing something? I am inexperienced in this domain so please guide me on how to fix this issue. I have attached snaps of my Recovery and Factory modes.

TLDR; phone ends up in bootloop after suddenly restarting while in use, battery drains faster, no ultrafast charging, clearing cache and factory reset doesn’t help.

## arrays – Returning random integer from interval based on last result and a seed

Suppose we have an interval of integers (a, b). I would like to have a function that returns random members from within the interval, without repetitions. Once that all members within the interval are explored, the function would start to return the same first random sequence again, in the same order.

Example: a=1, b=5

``````3, 1, 4, 5, 2, 3, 1, 4, 5, 2, 3, 1, 4, 5, 2, ...
``````

This would be easy to achieve by shuffling an array of all elements between a and b, and repeating it once the array is finished. However, this would take too much memory space, and this is not suitable for my case (I might have millions of elements).

Instead, the function I’d like to have would be more or less like this:

``````f(a, b, n, seed) -> n+1
``````

Where:

``````a - start of interval
b - end of interval
n - last element returned from list
seed - self-explanatory
n+1 - next random element from list, calculated by using the seed and the last element returned (n)
``````

The trick is knowing some way to get a non-repeated number from the interval based only on the element returned before and the seed. In the end, it would behave like a circular list randomized at its initialization, but without using memory space.

## matlab – Does frequent changing of the random seed reduce the randomness of results?

I wrote a Matlab program whose algorithm is like:

``````for epoch = 1:1000,
rng('shuffle') %seed based on time
for generation = 1:100,
% solve the puzzle using the random number to shuffle values in the puzzle
end
end
``````

`rng` seeds the random number generator based on the current system time. I’m using Matlab’s default random number generator, and the reason I put `rng` within the epoch loop, is because I wanted to make sure the puzzle got solved differently each time.

But, one of the conference reviewers wrote a review comment that said:

“One normally seeds a PRNG (pseudo random number generator” once
during initialisation. Changing the seed repeatedly REDUCES the
randomness of results!!!! Move this out of your algorithm. Low
diversity in a PRNG can actually improve results!”

Is this actually true? Would my program have produced better randomness if the seed was initialized like this?

``````rng('shuffle') %seed based on time
for epoch = 1:1000,
for generation = 1:100,
% solve the puzzle using the random number to shuffle values in the puzzle
end
end
``````

When I thought through it, I realized he may have meant that changing the random seed within an epoch may result in one or more epochs starting from the same random seed, and that’s why it may reduce the randomness. Is there any other explanation or is the reviewer’s understanding flawed?

## st.statistics – Is linear combination of dependent exponential family random variables(multinomial, normal) in exponential family?

As well known to us, multinomial distribution and normal distribution belong to exponential family. Define
$$Z = sum_{i=1}^{n}a_{i}(X_{i} – b_{i}) + sum_{j=1}^{m}c_{j}Y_{j},$$
where $$X_{i}$$ is multinomial random variable, $$Y_{j}$$ is normal random variable, $$a_{i}, b_{i}, c_{j}$$ are constants. Additionally, $$X_{i}, Y_{j} (i = 1,2,cdots,n, j = 1,2,cdots,m)$$ are dependent.

Question: does the distribution of random variable $$Z$$ belong to exponential family?

Furthermore, in general, does the distribution of linear combination of exponential family random variables belong to exponential family?

If yes, can you provide a rigorous proof or a reference? Otherwise, can you provide a counterexample?

Thank you in advance!

## c# – Cómo poner en random las posiciones de los objetos dentro de un Grid Layout Group en UNITY?

intento intercambiar posiciones de 4 objetos, mejor si es aleatorio. Los objetos están dentro de un Grid Layout Group de Unity. O sea, cada que inicie se cambie la posición(donde esta el rojo aparezca el azul, donde esta el verde, el amarillo, etc.), por favor no sean duros con lo poco que avancé.

``````using UnityEngine;

using UnityEngine.UI;
using UnityEngine.UIElements;

public class CajitaRandom : MonoBehaviour
{

public GridLayoutGroup cajita;
void Start()
{
cajita.GetComponentInChildren<Position>(Random);
}
``````

## python – Hex boardgame with fast random rollouts (OpenAI gym framework)

I implemented the boardgame Hex using the OpenAI gym framework with the aim of building a bot/AI player that can learn through self-play and expert iteration (details Note: not my paper; I am merely reproducing it).

The initial agent uses Monte-Carlo tree search (MCTS), and I will compare myself against it to evaluate the strength of different bots. MCTS involves simulating the game with random moves (called a rollout) and this is done A LOT (>1,000 games played per move in the actual game), so this rollout speed matters to me. Indeed, when I profile my code, the bottleneck is said rollout, and, more specifically, the test if the game has ended.

Currently, I check if the game is finished using the following mechanism (I’m sure there is a name for it, but I don’t know it):

1. Pad the board with 1 extra row/column and place stones on the west/east side (player white/blue) or north/south side (player black/red) (cached at the start of the game)
2. Find all the connected regions for the current player (cached from previous turn)
3. Place stone on board
4. check neighborhood of stone and (a) start new region if unconnected, (b) add to the region with lowest region index
5. if multiple regions are in the neighborhood, merge them with the region that has the lowest index

I assign index 1 to the stones in the north/west (black/white) padding, and can then efficiently test if the game is over by checking the south-east corner. If it has region index 1, it is connected to the opposite side and the game has finished.

The full code of the game is available on GitHub together with a MWE that performs a random rollout. It’s not a big repo (maybe 500 lines). The critical function is this one

``````    def flood_fill(self, position):
regions = self.regions(self.active_player)

current_position = (position(0) + 1, position(1) + 1)
low_x = current_position(1) - 1
high_x = current_position(1) + 2
low_y = current_position(0) - 1
high_y = current_position(0) + 2
neighbourhood = regions(low_y:high_y, low_x:high_x).copy()
neighbourhood(0, 0) = 0
neighbourhood(2, 2) = 0
adjacent_regions = sorted(set(neighbourhood.flatten().tolist()))
adjacent_regions.pop(0)

if len(adjacent_regions) == 0:
regions(tuple(current_position)) = self.region_counter(self.active_player)
self.region_counter(self.active_player) += 1
else:
new_region_label = adjacent_regions.pop(0)
regions(tuple(current_position)) = new_region_label
for label in adjacent_regions:
regions(regions == label) = new_region_label
``````

with the most expensive line being `adjacent_regions = sorted(set(neighbourhood.flatten().tolist()))`. I’m wondering if this can be implemented in a nicer way, either by using a different algorithm or vectorizing the code more, more intelligent caching, …

Of course, I’m also happy with any other comment on the code.

Disclaimer: I found a basic hex implementation in an old commit in the OpenAI gym repo, which I used as a base to work off. Most of the code has changed, but some of it (e.g., the render function) I did not write myself.

## boot – How to hadle installation problems? Random freezes and black screen

I’ve been using linux mint for several months and then decided to install ubuntu + windows on my pc.
I did sucessfully installed windows 10, but ubuntu installations led to random freezes – some happened on the installations stage, others – after using it after few seconds after installation.
I tried to switch back to linux mint and problem happened again.
I’ve tried to use all method of rewriting disk – total rewrite, making my parts (including efi + swap), and all of attempt failed.

Now I can’t even make my mint system work even turn on – there just black screen with flickering underscore. I guess I have some hardware issues – I want to know – could I fix them, or I have to buy new ones?

Here is screenshot containing errors displaying after turning off PC after installations process

My inxi -Fxz:

``````System:
Kernel: 5.4.0-26-generic x86_64 bits: 64 compiler: gcc v: 9.3.0
Desktop: Cinnamon 4.6.6 Distro: Linux Mint 20 Ulyana
base: Ubuntu 20.04 focal
Machine:
Type: Laptop System: HP product: OMEN by HP Laptop 17-an0xx v: N/A
serial: <filter>
Mobo: HP model: 8392 v: 40.26 serial: <filter> UEFI: American Megatrends
v: F.15 date: 02/26/2018
Battery:
ID-1: BAT0 charge: 19.6 Wh condition: 75.7/75.7 Wh (100%)
model: HP Primary status: Discharging
CPU:
Topology: Quad Core model: Intel Core i5-7300HQ bits: 64 type: MCP
arch: Kaby Lake rev: 9 L2 cache: 6144 KiB
flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
bogomips: 19999
Speed: 800 MHz min/max: 800/3500 MHz Core speeds (MHz): 1: 892 2: 898
3: 895 4: 887
Graphics:
Device-1: Intel HD Graphics 630 vendor: Hewlett-Packard driver: N/A
bus ID: 00:02.0
Device-2: NVIDIA GP107M (GeForce GTX 1050 Mobile) vendor: Hewlett-Packard
driver: N/A bus ID: 01:00.0
Display: x11 server: X.Org 1.20.8 driver: fbdev unloaded: modesetting,vesa
resolution: 1920x1080~77Hz
OpenGL: renderer: llvmpipe (LLVM 9.0.1 256 bits) v: 3.3 Mesa 20.0.4
direct render: Yes
Audio:
Device-1: Intel CM238 HD Audio vendor: Hewlett-Packard
driver: snd_hda_intel v: kernel bus ID: 00:1f.3
Device-2: NVIDIA GP107GL High Definition Audio driver: snd_hda_intel
v: kernel bus ID: 01:00.1
Sound Server: ALSA v: k5.4.0-26-generic
Network:
Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
vendor: Hewlett-Packard driver: r8169 v: kernel port: c000 bus ID: 03:00.0
IF: eno1 state: down mac: <filter>
Device-2: Intel Wireless 7265 driver: iwlwifi v: kernel port: c000
bus ID: 04:00.0
IF: wlo1 state: up mac: <filter>
Drives:
Local Storage: total: 1.05 TiB used: 1.96 GiB (0.2%)
ID-1: /dev/nvme0n1 vendor: Samsung model: MZVLW128HEGR-000H1
size: 119.24 GiB
ID-2: /dev/sda vendor: HGST (Hitachi) model: HTS721010A9E630
size: 931.51 GiB
ID-3: /dev/sdb type: USB vendor: Generic model: Flash Disk size: 29.30 GiB
Partition:
ID-1: / size: 3.83 GiB used: 114.7 MiB (2.9%) fs: overlay source: ERR-102
ID-2: swap-1 size: 9.31 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sda4
Sensors:
System Temperatures: cpu: 46.0 C mobo: N/A
Fan Speeds (RPM): N/A
Info:
Processes: 206 Uptime: 7m Memory: 7.66 GiB used: 1.71 GiB (22.3%)
Init: systemd runlevel: 5 Compilers: gcc: 9.3.0 Shell: bash v: 5.0.16
inxi: 3.0.38
``````