Anthony Liu [EMAIL PROTECTED] writes:
OK, I actually just want to manually create Hidden
Markov Models by randomly generating the initial state
probabilities PI,
OK, this sounds like you actually want to divide the unit interval up
into pieces of varying sizes. Example (untested):
n = 10
fumanchu [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I'm surprised noone has pursued a course of subtraction rather than
division.
I believe someone did mention the subtraction method in one of the initial
responses. But the problem is this. If you independently sample n
Nick Craig-Wood wrote:
Gerard Flanagan [EMAIL PROTECTED] wrote:
def distribution(N=2):
p = [0] + sorted( random.random() for _ in range(N-1) ) + [1]
for j in range(N):
yield p[j+1] - p[j]
spread = list(distribution(10))
print spread
print sum(spread)
I'm surprised noone has pursued a course of subtraction rather than
division. Say you want 10 numbers:
s = 1.0
n = []
for x in xrange(9):
... value = random.random() * s
... n.append(value)
... s -= value
...
n.append(s)
n
[0.727922901516, 0.082128708606867745,
fumanchu [EMAIL PROTECTED] wrote:
I'm surprised noone has pursued a course of subtraction rather than
division. Say you want 10 numbers:
s = 1.0
n = []
for x in xrange(9):
... value = random.random() * s
... n.append(value)
... s -= value
...
n.append(s)
n
Alex Martelli wrote:
fumanchu [EMAIL PROTECTED] wrote:
I'm surprised noone has pursued a course of subtraction rather than
division. Say you want 10 numbers:
s = 1.0
n = []
for x in xrange(9):
... value = random.random() * s
... n.append(value)
... s -= value
...
n.append(s)
n
Alex Martelli wrote:
Such total disuniformity, where the very distribution of each value is
skewed by the preceding one, may still be random for some sufficiently
vague meaning of random, but my intuition suggests it's unlikely to
prove satisfactory for the OP's purposes.
It does seem very
Anthony Liu [EMAIL PROTECTED] wrote:
...
As a matter of fact, given that we have to specify the
number of states for an HMM, I would like to create a
specified number of random floating numbers whose sum
is 1.0.
def forAL(N):
N_randoms = [random.random() for x in xrange(N)]
total
Anthony Liu wrote:
I am at my wit's end.
I want to generate a certain number of random numbers.
This is easy, I can repeatedly do uniform(0, 1) for
example.
But, I want the random numbers just generated sum up
to 1 .
I am not sure how to do this. Any idea? Thanks.
Gerard Flanagan wrote:
Anthony Liu wrote:
I am at my wit's end.
I want to generate a certain number of random numbers.
This is easy, I can repeatedly do uniform(0, 1) for
example.
But, I want the random numbers just generated sum up
to 1 .
I am not sure how to do this. Any
Gerard Flanagan wrote:
Gerard Flanagan wrote:
Anthony Liu wrote:
I am at my wit's end.
I want to generate a certain number of random numbers.
This is easy, I can repeatedly do uniform(0, 1) for
example.
But, I want the random numbers just generated sum up
to 1 .
I
Thanks a lot, Alex and Gerard.
I am actually not very concerned about the
inter-dependency of the floating numbers generated
randomly. They are good enough if they are subject to
the constraint of summing up to 1.
It is simply not worth the time to get an HMM by
training it on a large corpus.
Gerard Flanagan [EMAIL PROTECTED] wrote:
def distribution(N=2):
p = [0] + sorted( random.random() for _ in range(N-1) ) + [1]
for j in range(N):
yield p[j+1] - p[j]
spread = list(distribution(10))
print spread
print sum(spread)
This is simpler, easier to prove
I am at my wit's end.
I want to generate a certain number of random numbers.
This is easy, I can repeatedly do uniform(0, 1) for
example.
But, I want the random numbers just generated sum up
to 1 .
I am not sure how to do this. Any idea? Thanks.
Anthony Liu wrote:
I am at my wit's end.
I want to generate a certain number of random numbers.
This is easy, I can repeatedly do uniform(0, 1) for
example.
But, I want the random numbers just generated sum up
to 1 .
I am not sure how to do this. Any idea? Thanks.
Anthony Liu wrote:
I am at my wit's end.
I want to generate a certain number of random numbers.
This is easy, I can repeatedly do uniform(0, 1) for
example.
But, I want the random numbers just generated sum up
to 1 .
I am not sure how to do this. Any idea? Thanks.
numbers.append
Anthony Liu wrote:
But, I want the random numbers just generated sum up
to 1 .
This seems like an odd request. Might I ask what it's for?
Generating random numbers in [0,1) that are both uniform and sum to 1 looks
like an unsatisfiable task. Each number you generate restricts the
Em Sáb, 2006-04-22 às 03:16 +, Edward Elliott escreveu:
If that level of accuracy
matters, you might consider generating your rands as integers and then
fp-dividing by the sum (or just store them as integers/fractions).
Or using decimal module:
OK, I actually just want to manually create Hidden
Markov Models by randomly generating the initial state
probabilities PI, the transition probabilities A and
the emission probabilities B, instead of learning such
statistics from a corpus. They have to be subject the
constraint that
sum(PI) =
19 matches
Mail list logo