markov-chains

Using Markov chains (or something similar) to produce an IRC-bot

两盒软妹~` 提交于 2019-12-02 15:38:47
I tried google and found little that I could understand. I understand Markov chains to a very basic level: It's a mathematical model that only depends on previous input to change states..so sort of a FSM with weighted random chances instead of different criteria? I've heard that you can use them to generate semi-intelligent nonsense, given sentences of existing words to use as a dictionary of kinds. I can't think of search terms to find this, so can anyone link me or explain how I could produce something that gives a semi-intelligent answer? (if you asked it about pie, it would not start going

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

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 program bigram as a table in python?

无人久伴 提交于 2019-12-02 07:59:28
I'm doing this homework, and I am stuck at this point. I can't program Bigram frequency in the English language , 'conditional probability' in python? That is, the probability of a token given the preceding token is equal to the probability of their bigram, or the co-occurrence of the two tokens , divided by the probability of the preceding token. I have a text with many letters, then I have calculated the probability for the letters in this text, so the letter 'a' appears 0.015% compared to the letters in the text. The letters are from ^a-zA-Z , and what I want is: How can I make a table with

Generating a pseudo-natural phrase from a big integer in a reversible way

戏子无情 提交于 2019-12-01 17:56:59
I have a large and "unique" integer (actually a SHA1 hash). Note: While I'm talking here about SHA1 hashes, this is not a cryptography / security question! I'm not trying to break SHA1. Imagine a random 160-bit integer instead of SHA1 if that will help. I want (for no other reason than to have fun) to find an algorithm to map that SHA1 hash to a computer-generated (pseudo-)English phrase. The mapping should be bidirectional (i.e., knowing the algorithm, one must be able to calculate the original SHA1 hash from that phrase.) The phrase need not make sense. I would even settle for a whole

Generating a pseudo-natural phrase from a big integer in a reversible way

*爱你&永不变心* 提交于 2019-12-01 17:39:23
问题 I have a large and "unique" integer (actually a SHA1 hash). Note: While I'm talking here about SHA1 hashes, this is not a cryptography / security question! I'm not trying to break SHA1. Imagine a random 160-bit integer instead of SHA1 if that will help. I want (for no other reason than to have fun) to find an algorithm to map that SHA1 hash to a computer-generated (pseudo-)English phrase. The mapping should be bidirectional (i.e., knowing the algorithm, one must be able to calculate the

How to test if a string contains gibberish in PHP?

僤鯓⒐⒋嵵緔 提交于 2019-11-30 15:08:25
问题 I am making a registering form for a website and because I'm sure everyone is going to enter some gibberish in the Secret Answer's input (I do that myself), I would like to programmatically test that value to see if it's more likely to be a good answer. I have taken a look at a function that generates Markov Chains (see at bottom) in PHP but I don't know how to test a string against that chains' Array to actually detect the % accuracy of the given answer. Has anyone here did something similar

How to test if a string contains gibberish in PHP?

戏子无情 提交于 2019-11-30 13:28:32
I am making a registering form for a website and because I'm sure everyone is going to enter some gibberish in the Secret Answer's input (I do that myself), I would like to programmatically test that value to see if it's more likely to be a good answer. I have taken a look at a function that generates Markov Chains (see at bottom) in PHP but I don't know how to test a string against that chains' Array to actually detect the % accuracy of the given answer. Has anyone here did something similar ? How you solved it or have you given up ? Thank you function generateCaptchaTextMarkov($length) {

Constructing a multi-order Markov chain transition matrix in Matlab

纵然是瞬间 提交于 2019-11-30 02:25:35
A first-order transition matrix of 6 states can be constructed very elegantly as follows x = [1 6 1 6 4 4 4 3 1 2 2 3 4 5 4 5 2 6 2 6 2 6]; % the Markov chain tm = full(sparse(x(1:end-1),x(2:end),1)) % the transition matrix. So here is my problem, how do you construct a second-order transition matrix elegantly? The solution I came up with is as follows [si sj] = ndgrid(1:6); s2 = [si(:) sj(:)]; % combinations for 2 contiguous states tm2 = zeros([numel(si),6]); % initialize transition matrix for i = 3:numel(x) % construct transition matrix tm2(strmatch(num2str(x(i-2:i-1)),num2str(s2)),x(i))=...

Building a Transition Matrix using words in Python/Numpy

六月ゝ 毕业季﹏ 提交于 2019-11-29 21:41:10
问题 Im trying to build a 3x3 transition matrix with this data days=['rain', 'rain', 'rain', 'clouds', 'rain', 'sun', 'clouds', 'clouds', 'rain', 'sun', 'rain', 'rain', 'clouds', 'clouds', 'sun', 'sun', 'clouds', 'clouds', 'rain', 'clouds', 'sun', 'rain', 'rain', 'sun', 'sun', 'clouds', 'clouds', 'rain', 'rain', 'sun', 'sun', 'rain', 'rain', 'sun', 'clouds', 'clouds', 'sun', 'sun', 'clouds', 'rain', 'rain', 'rain', 'rain', 'sun', 'sun', 'sun', 'sun', 'clouds', 'sun', 'clouds', 'clouds', 'sun',