Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7518021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:38:06+00:00 2026-05-30T01:38:06+00:00

I have sth like this: empty=0 full=1 burn=2 myprob=0.7 if cell==burn: return (empty or

  • 0

I have sth like this:

empty=0
full=1
burn=2
myprob=0.7

if cell==burn:
   return (empty or full) with probability  myprob

How can i do it?
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:38:07+00:00Added an answer on May 30, 2026 at 1:38 am

    The expression

    numpy.random.random() < myprob
    

    will evaluate to True with probability myprob. Since False and True interpreted as integers are 0 and 1, you can use

    [empty, full][numpy.random.random() < myprob]
    

    to select between the two given values with the given probability. For your particular values of empty and full, the first expression will basically do the same — you only need the second one if empty and full aren’t 0 and 1 respectively.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to construct new variable in C#. I mean, to have sth like this
iI have some trouble getting sth like this to work in java: public class
I have a sql like this: SELECT * FROM tableA WHERE column_a = sth
i have the following problem using jquery. I have sth like this <div id=yxz
I have some troubles with parsing matrix file. It looks sth like this: #
I have just installed darcs 2.1.2.2. When I type darcs help, sth less-like shows
User model looks sth like this: before_save :ensure_authentication_token devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable,
i have these: a=sc.array([0,1]) b=sc.array([1,0]) c=sc.array([0,-1]) d=sc.array([-1,0]) orientation_list=(sc.array([a,b,c,d])).tolist() #--------------------------------------------------------------------- #i am trying sth like
I have this : def steps(ns): return [random.choice([[0, 1], [1, 0], [0, -1], [-1,
I have sth like that. It's giving me error. I cut out all unneeded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.