天道酬勤,学无止境

probability

完美 32 位 crc 的预期冲突(Expected collisions for perfect 32bit crc)

问题 我正在尝试确定我的 crc 与“理想的”32 位 crc 相比如何。 所以我运行了超过 100 万个完全随机的数据样本并收集了碰撞数量,我想将这个数字与我可以从“理想”CRC 中预期的碰撞数量进行比较。 有谁知道如何计算“理想” 32 位 crc 的预期碰撞? 回答1 将您自己的 CRC 与 0x1EDC6F41 比较作为您的“理想”参考。 话虽如此,没有理想的 32 位 CRC。 根据散列数据的长度,不同的多项式具有不同的冲突特性。 然而,Castagnoli 在 1993 年的一篇论文发现,在最广泛的数据长度范围内,即 0x1EDC6F41,被认为是最好的 32 位 CRC 值。 这个多项式被一些网络协议使用,比如 iSCSI 和 x86 CRC32 指令。 回答2 这很好地解释了“生日问题”以及所有关于预测碰撞概率 CRC32 Hash Collision Probability

2021-06-24 03:52:30    分类:技术分享    probability   crc   crc32   probability-theory

naive classifier matlab

When testing the naive classifier in matlab I get different results even though I trained and tested on the same sample data, I was wondering if my code is correct and if someone could help explain why this is? %% dimensionality reduction columns = 6 [U,S,V]=svds(fulldata,columns); %% randomly select dataset rows = 1000; columns = 6; %# pick random rows indX = randperm( size(fulldata,1) ); indX = indX(1:rows)'; %# pick random columns %indY = randperm( size(fulldata,2) ); indY = indY(1:columns); %# filter data data = U(indX,indY); %% apply normalization method to every cell data = zscore(data)

2021-06-24 00:46:40    分类:问答    matlab   machine-learning   classification   probability   naivebayes

Can you return n choose k combinations in Javascript using Array.flatMap?

For instance, this is 5 choose 2: var array = [0,1,2,3,4]; var result = array.flatMap( (v, i) => array.slice(i+1).map(w => [v, w]) ); console.log(result); How would I be able to do 5 choose 3 using this method?

2021-06-23 23:32:54    分类:问答    javascript   arrays   probability

Ruby - Picking an element in an array with 50% chance for a[0], 25% chance for a[1]

Nothing too complicated, basically I just want to pick an element from the array as if I were making coin tosses for each index and and choosing the index when I first get a head. Also no heads means I choose the last bin. I came up with the following and was wondering if there was a better/more efficient way of doing this. def coin_toss(size) random_number = rand(2**size) if random_number == 0 return size-1 else return (0..size-1).detect { |n| random_number[n] == 1 } end end

2021-06-23 19:24:07    分类:问答    ruby   probability

Weighted random map

Suppose I have a big 2D array of values in the range [0,1] where 0 means "impossible" and 1 means "highly probable". How can I select a random set of points in this array according to the probabilities described above ?

2021-06-23 16:24:35    分类:问答    algorithm   language-agnostic   random   probability

Calculating probability for FUNPROB

Regarding - FUNPROB The solution is : int N, M; while(1) { scanf("%d %d", &N, &M); if (0 == N && 0 == M) break; if (N > M) printf("0.000000\n"); else { double res = (double) (M-N+1) / (M+1); printf("%.6f\n", res); } } My question is regarding line res = (M-N+1) / (M+1); How to arrive at the conclusion that the probability is calculated in this way ?

2021-06-23 10:18:44    分类:问答    c++   math   probability

How can I sample a multivariate log-normal distribution in Python?

Using Python, how can I sample data from a multivariate log-normal distribution? For instance, for a multivariate normal, there are two options. Let's assume we have a 3 x 3 covariance matrix and a 3-dimensional mean vector mu. # Method 1 sample = np.random.multivariate_normal(mu, covariance) # Method 2 L = np.linalg.cholesky(covariance) sample = L.dot(np.random.randn(3)) + mu I found numpy's numpy.random.lognormal, but that only seems to work for univariate samples. I also noticed scipy's scipy.stats.lognorm. This does seem to have the potential for multivariate samples. However, I can't

2021-06-23 06:29:36    分类:问答    python   numpy   statistics   scipy   probability

找到有限空间中位数的概率(Probability of finding the median with finite space)

问题 这是这个 StackOverflow 问题的衍生。 假设您有固定数量的k个存储位置和两个计数器的空间。 您将收到以随机顺序n项(n个项目的所有排列都是等可能的)。 收到每个项目后,您可以将其存储在k 个位置之一(丢弃先前存储的值之一),或者丢弃该项目。 您还可以增加或减少任一计数器。 任何丢弃的物品都无法找回。 问题是 使您找到确切中位数的概率最大化的策略是什么? 那概率是多少? 显然,如果k > n/2 ,我们可以找到中位数。 一般来说,试图保持丢弃的高值的数量等于丢弃的低值的数量的相同策略似乎应该是最佳的,但我不确定如何证明它,也不知道如何计算它找到的概率中位数。 同样感兴趣的是,我们不知道n,而是知道n的概率分布的情况。 编辑:现在假设这些值是不同的(没有重复)。但是,如果您也可以解决非不同的情况,那将会令人印象深刻。 回答1 Munro 和 Paterson 在他们的论文Selection and sorts with limited storage 中从本质上研究了这个问题。 它们表明,您的算法需要 k = Ω(√n) 才能以恒定概率成功,并且通过吸引有关一维随机游走的基本结果,这是渐近最优的。 如果我想证明绝对最优性,我会尝试的第一件事是考虑任意算法 A,然后将其执行与算法 A' 结合起来,当 A 第一次偏离您的算法时,您的算法是否会改为执行然后尝试尽可能紧跟 A

2021-06-23 04:10:55    分类:技术分享    algorithm   probability

Java- Math.random(): Selecting an element of a 13 by 13 triangular array

Edit: This problem is solved. If you would like to help on another problem, please visit Java Biasing Random Numbers in a Triangular Array. I'm doing a multiplication game, so I pick 2 numbers between 0 and 12 inclusive. If I do that like this: int num1 = (int)(Math.random() * 13); int num2 = (int)(Math.random() * 13); the squares (0x0,1x1,2x2,etc) are picked half the time (because 1x2 is the same as 2x1). How can I make all combinations picked at the same frequency? There are 91 possible combinations (n(n+1)/2). If it helps, here is a 13 by 13 triangular array: {{0}, {0,0}, {0,0,0}, {0,0,0,0}

2021-06-23 02:04:32    分类:问答    java   math   random   probability

Generating numbers with certain probabilities visual basics vba

I have some probabilities of 26% 18% 26% 20% 10% and I want to generate some numbers (randomly in a certain range) based on the probability groups. I have done that previously with 2 probabilities of 80% and 20% like below: If rnd*100 < 80 then Output = 2 Else output = 10 End if But I am not sure how to do that with more than 2 probabilities!

2021-06-22 23:01:10    分类:问答    vba   random   probability