Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93426

Re: "normalizing" a value

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 <skip.montanaro@gmail.com>
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 <fd370a7b-ea6a-48e5-90f4-9d86b89a745e@googlegroups.com>
References <fd370a7b-ea6a-48e5-90f4-9d86b89a745e@googlegroups.com>
Date Thu, 2 Jul 2015 10:05:42 -0500
Subject Re: "normalizing" a value
From Skip Montanaro <skip.montanaro@gmail.com>
To bvdp <bob@mellowood.ca>
Cc Python <python-list@python.org>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.244.1435849550.3674.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

"normalizing" a value bvdp <bob@mellowood.ca> - 2015-07-01 17:12 -0700
  Re: "normalizing" a value MRAB <python@mrabarnett.plus.com> - 2015-07-02 01:30 +0100
  Re: "normalizing" a value Paul Rubin <no.email@nospam.invalid> - 2015-07-01 17:36 -0700
  Re: "normalizing" a value Denis McMahon <denismfmcmahon@gmail.com> - 2015-07-02 01:06 +0000
  Re: "normalizing" a value random832@fastmail.us - 2015-07-01 21:27 -0400
    Re: "normalizing" a value bvdp <bob@mellowood.ca> - 2015-07-01 18:49 -0700
      Re: "normalizing" a value random832@fastmail.us - 2015-07-01 22:23 -0400
        Re: "normalizing" a value bvdp <bob@mellowood.ca> - 2015-07-01 19:41 -0700
      Re: "normalizing" a value Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-07-01 23:36 -0400
        Re: "normalizing" a value bvdp <bob@mellowood.ca> - 2015-07-02 10:03 -0700
  Re: "normalizing" a value Steven D'Aprano <steve@pearwood.info> - 2015-07-02 12:15 +1000
    Re: "normalizing" a value bvdp <bob@mellowood.ca> - 2015-07-01 19:42 -0700
  Re: "normalizing" a value Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-02 05:41 +0100
  Re: "normalizing" a value Skip Montanaro <skip.montanaro@gmail.com> - 2015-07-02 10:05 -0500

csiph-web