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 8007571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:52:25+00:00 2026-06-04T17:52:25+00:00

following problem: Having a base triple (0,1,0) Now I try to create a list

  • 0

following problem: Having a base triple (0,1,0)

Now I try to create a list of changed triples in a given range.

The constraints:

  1. triple[0] and triple[2] have should have a maximum of r, such as r=0.2
  2. sum(triple) = 1
  3. triple[0] needn’t to be equals triple[1] and should be increased by a given stepwise-parameter s, such as s= 0.02

In this above mentioned example our methode should create

lst = [(0.0, 1, 0.0),(0.02, 0.98, 0.), (0.04, 0.96,0), (0.04,0.94, 0.02), (0.06,0.94,0), (0.06, 0.92, 0.02), (0.06, 0.9, 0.04), ...]

Is there any pretty way to do this?

Maybe you have an idea to create these list without nested loops (probably with numpy?).

Thanks a lot!

  • 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-06-04T17:52:27+00:00Added an answer on June 4, 2026 at 5:52 pm

    Here’s a list comprehension that should provide all 3-tuples that meet your constraints (as I understand them). Its a bit more clunky than I’d like due to the range function only accepting integers:

    r = 0.2
    s = 0.02
    steps = int(math.ceil(r/s))
    lst = [(a*s, 1-(a+b)*s, b*s) for b in range(steps) for a in range(steps)]
    

    Results:

    >>> lst[0:4]
    [(0.0, 1.0, 0.0), (0.02, 0.98, 0.0), (0.04, 0.96, 0.0), (0.06, 0.94, 0.0)]
    >>> lst[90:94]
    [(0.0, 0.8200000000000001, 0.18), (0.02, 0.8, 0.18), (0.04, 0.78, 0.18), (0.06, 0.76, 0.18)]
    

    The first and last values only go up to 0.18 in this code, and I’m not sure if that’s desirable or not (is the constraint < r or <= r?). It shouldn’t be too hard to tweak, if you want it the other way.

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

Sidebar

Related Questions

I'm having the following problem using Django with MySQL 5.5.22. Given a table with
I have been having the following problem, i think it's probably due to the
I'm having a problem testing the following model: class Bill < ActiveRecord::Base belongs_to :consignee
the problem is the following. We have a (rather large) code base in form
I have this base class having the following interface: abstract class Base { abstract
I'm having following problem. I should convert a control to a certain type, this
I'm having the following problem and wondered whether anyone could see why this is
I'm having the following problem using the Visual Studio 2010 Team System Beta 1:
I'm having the following problem: When I got two labels into each other: <Label
I'm having the following problem when using GWT and request factory. I am working

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.