Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.039 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'linear': 0.07; 'cc:addr :python-list': 0.10; '3):': 0.16; '50)': 0.16; 'skip': 0.18; 'input': 0.18; '>>>': 0.20; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; '(like': 0.23; 'header:In-Reply-To:1': 0.24; 'scale': 0.27; 'message-id:@mail.gmail.com': 0.28; 'looks': 0.29; '50,': 0.29; 'way?': 0.29; 'values': 0.30; 'print': 0.31; 'add': 0.34; 'received:google.com': 0.34; 'subject:" ': 0.36; 'some': 0.40; 'your': 0.60; '100': 0.79; '-44': 0.84; 'subject:value': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=OVuZebeLg+lUgcDkXAM9q2sTuS2sZ4PUggpm2VcKlQs=; b=eIB9xbG2pUWBguYnjVWHv3XvxTsdvRi+0GuwhGvCNbjEJYSxUuJug0t0FCtc4HfoFe vO3wRmxz1UmI0SBqV50xO5Pnaum3VGuo7yDSvsXltxcPmY1gB2uTXXmLNuhuhW0oE5RZ LZHJu4IJataT8yY8PGD4LXj7Vk1Kdmc1dAA/3emBFC5Xytm8hr0TQzdtB/0KXSUvhR1Z kS5AKZhYwyZfBszNir3wcsReFr0pJ2sfZV9C2lwzzK3WwqBB8uutX913o1mySfm3khRl vW0uMN41aOgYEcAZzlobrKQYHwmTjPAxkyxynhUNAkgYPnbGUm1DPSaMJDyXvh2cAe5q oxSw== MIME-Version: 1.0 X-Received: by 10.50.90.179 with SMTP id bx19mr43129842igb.43.1435849542151; Thu, 02 Jul 2015 08:05:42 -0700 (PDT) In-Reply-To: References: Date: Thu, 2 Jul 2015 10:05:42 -0500 Subject: Re: "normalizing" a value From: Skip Montanaro To: bvdp Cc: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435849550 news.xs4all.nl 2824 [2001:888:2000:d::a6]:60964 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93426 This looks like a straightforward linear transformation issue to me (like Fahrenheit to Celsius). Add 50 to all input values, giving you values in the range 0 to 100. Then scale them into your 0 to 12 range by multiplying them by 12/100: >>> for n in range(-50, 50, 3): ... print n, n + 50, (n + 50) * 12 / 100 ... -50 0 0.0 -47 3 0.36 -44 6 0.72 -41 9 1.08 -38 12 1.44 ... 34 84 10.08 37 87 10.44 40 90 10.8 43 93 11.16 46 96 11.52 49 99 11.88 Did I misread your request in some way? Skip