probability

Create Bayesian Network and learn parameters with Python3.x

北战南征 提交于 2019-12-02 14:42:58
I'm searching for the most appropriate tool for python3.x on Windows to create a Bayesian Network, learn its parameters from data and perform the inference. The network structure I want to define myself as follows: It is taken from this paper. All the variables are discrete (and can take only 2 possible states) except "Size" and "GraspPose", which are continuous and should be modeled as Mixture of Gaussians. Authors use Expectation-Maximization algorithm to learn the parameters for conditional probability tables and Junction-Tree algorithm to compute the exact inference. As I understand all is

An interview question: About Probability

假如想象 提交于 2019-12-02 13:59:41
An interview question: Given a function f(x) that 1/4 times returns 0, 3/4 times returns 1. Write a function g(x) using f(x) that 1/2 times returns 0, 1/2 times returns 1. My implementation is: function g(x) = { if (f(x) == 0){ // 1/4 var s = f(x) if( s == 1) {// 3/4 * 1/4 return s // 3/16 } else { g(x) } } else { // 3/4 var k = f(x) if( k == 0) {// 1/4 * 3/4 return k // 3/16 } else { g(x) } } } Am I right? What's your solution?(you can use any language) If you call f(x) twice in a row, the following outcomes are possible (assuming that successive calls to f(x) are independent, identically

How do Markov Chain Chatbots work?

好久不见. 提交于 2019-12-02 13:48:23
I was thinking of creating a chatbot using something like markov chains, but I'm not entirely sure how to get it to work. From what I understand, you create a table from data with a given word and then words which follow. Is it possible to attach any sort of probability or counter while training the bot? Is that even a good idea? The second part of the problem is with keywords. Assuming I can already identify keywords from user input, how do I generate a sentence which uses that keyword? I don't always want to start the sentence with the keyword, so how do I seed the markov chain? Nocker I

can rand() be used to generate predictable data?

醉酒当歌 提交于 2019-12-02 12:31:26
My goal is generate 2D or 3D geometry without having to store it on disk, so my goal is to have any sort of function than generate the same values according to a small seed. I don't mean to seek random values, but if the same "random" garbage data is returned when given the same seed, that's something I'm looking for. If I give srand() the same integer, I get the same sequence out of rand(). Is that an intended feature ? If not, are there known standard functions designed to do the same thing ? Although I tried this on ideone and on my computer and I get different results, I can understand

mathematics behind modulo behavor

蓝咒 提交于 2019-12-02 11:44:07
Preamble This question is not about the behavior of (P)RNG and rand() . It's about using power of two values uniformly distributed against modulo. Introduction I knew that one should not use modulo % to convert a value from a range to another, for example to get a value between 0 and 5 from the rand() function: there will be a bias. It's explained here https://bitbucket.org/haypo/hasard/src/ebf5870a1a54/doc/common_errors.rst?at=default and in this answer Why do people say there is modulo bias when using a random number generator? But today after investigating some code which was looking wrong,

How do I randomly equalize unequal values?

戏子无情 提交于 2019-12-02 09:19:29
问题 Say I have multiple unequal values a, b, c, d, e. Is it possible to turn these unequal values into equal values just by using random number generation? Example: a=100, b=140, c=200, d=2, e=1000. I want the algorithm to randomly target these sets such that the largest value is targeted most often and the smallest value is left alone for the most parts. Areas where I've run into problems: if I just use non-unique random number generation, then value e will end up going under the other values.

Understanding Markov Chain source code in R

此生再无相见时 提交于 2019-12-02 08:20:40
The following source code is from a book. Comments are written by me to understand the code better. #================================================================== # markov(init,mat,n,states) = Simulates n steps of a Markov chain #------------------------------------------------------------------ # init = initial distribution # mat = transition matrix # labels = a character vector of states used as label of data-frame; # default is 1, .... k #------------------------------------------------------------------- markov <- function(init,mat,n,labels) { if (missing(labels)) # check if 'labels'

How do I generate random letters in java based on probability?

岁酱吖の 提交于 2019-12-02 07:33:02
I am having trouble generating random letters based on probability. For example, the letters J, K, Q, Y, Z each have a probability of 1/96 of occurring. A similar process (with higher probabilities) is used for other letters. Can somebody show me how to do this? Edit to be specific: I'm writing a method called "getRandomLetter" that returns a char of a random letter based on a probability fraction. The typical way to select from a discrete set of elements with specific probabilities is to choose a random floating-point number and find out which range it lies in. I'll explain with an example.

Generate a set of M elements from an array of size N

时光怂恿深爱的人放手 提交于 2019-12-02 07:20:48
UPDATE: according to the comments let's make some clarifications. I'm trying to understand solution for the following task: Randomly generate a set of M elements from an array of size N. Each element must have equal probability of being chosen. I found the following solution (I've already read this question , but it does not answer my question): int rand(Random random, int min, int max) { return random.nextInt(1 + max - min) + min; } char[] generateArray(char[] original, int subsetSize) { char[] subset = new char[subsetSize]; Random random = new Random(); for (int i = 0; i < subsetSize; i++) {

How do I randomly equalize unequal values?

偶尔善良 提交于 2019-12-02 06:59:32
Say I have multiple unequal values a, b, c, d, e. Is it possible to turn these unequal values into equal values just by using random number generation? Example: a=100, b=140, c=200, d=2, e=1000. I want the algorithm to randomly target these sets such that the largest value is targeted most often and the smallest value is left alone for the most parts. Areas where I've run into problems: if I just use non-unique random number generation, then value e will end up going under the other values. If I use unique number generation, then the ration between the values doesn't change even if their