Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

replaced http://1.bp.blogspot.com/_mGF7Mo1o9b4/SlT2s9H7g_I/AAAAAAAAABE/RYgqR4C3XSM/s400/entropy with https://1.bp.blogspot.com/_mGF7Mo1o9b4/SlT2s9H7g_I/AAAAAAAAABE/RYgqR4C3XSM/s400/entropy
Source Link
URL Rewriter Bot
URL Rewriter Bot

I want to build a Python function that calculates,

alt text http://1.bp.blogspot.com/_mGF7Mo1o9b4/SlT2s9H7g_I/AAAAAAAAABE/RYgqR4C3XSM/s400/entropyalt text

and would like to name my summation function Σ. In a similar fashion, would like to use Π for product, and so on. I was wondering if there was a way to name a python function in this fashion?

def Σ (..):
 ..
 ..

That is, does Python support unicode identifiers, and if so, could someone provide an example for it?

Thanks!


Original motivation for this was a piece of Clojure code I saw today that looks like,

(defn entropy [X]
 (* -1 (Σ [i X] (* (p i) (log (p i))))))

where Σ is a macro defined as,

(defmacro Σ
 ... )

and I thought that was pretty cool.


BTW, to address a couple of comments about readability - with a lot of stats/ML code for instance, being able to compose operations with symbols would be really helpful. (Especially for really complex integrals et al)

φ(z) = ∫(N(x|0,1,1), -∞, z)

vs

Phi(z) = integral(N(x|0,1,1), -inf, z)

or even just the lambda character for lambda()!

I want to build a Python function that calculates,

alt text http://1.bp.blogspot.com/_mGF7Mo1o9b4/SlT2s9H7g_I/AAAAAAAAABE/RYgqR4C3XSM/s400/entropy

and would like to name my summation function Σ. In a similar fashion, would like to use Π for product, and so on. I was wondering if there was a way to name a python function in this fashion?

def Σ (..):
 ..
 ..

That is, does Python support unicode identifiers, and if so, could someone provide an example for it?

Thanks!


Original motivation for this was a piece of Clojure code I saw today that looks like,

(defn entropy [X]
 (* -1 (Σ [i X] (* (p i) (log (p i))))))

where Σ is a macro defined as,

(defmacro Σ
 ... )

and I thought that was pretty cool.


BTW, to address a couple of comments about readability - with a lot of stats/ML code for instance, being able to compose operations with symbols would be really helpful. (Especially for really complex integrals et al)

φ(z) = ∫(N(x|0,1,1), -∞, z)

vs

Phi(z) = integral(N(x|0,1,1), -inf, z)

or even just the lambda character for lambda()!

I want to build a Python function that calculates,

alt text

and would like to name my summation function Σ. In a similar fashion, would like to use Π for product, and so on. I was wondering if there was a way to name a python function in this fashion?

def Σ (..):
 ..
 ..

That is, does Python support unicode identifiers, and if so, could someone provide an example for it?

Thanks!


Original motivation for this was a piece of Clojure code I saw today that looks like,

(defn entropy [X]
 (* -1 (Σ [i X] (* (p i) (log (p i))))))

where Σ is a macro defined as,

(defmacro Σ
 ... )

and I thought that was pretty cool.


BTW, to address a couple of comments about readability - with a lot of stats/ML code for instance, being able to compose operations with symbols would be really helpful. (Especially for really complex integrals et al)

φ(z) = ∫(N(x|0,1,1), -∞, z)

vs

Phi(z) = integral(N(x|0,1,1), -inf, z)

or even just the lambda character for lambda()!

added 328 characters in body; added 49 characters in body
Source Link
viksit
  • 7.8k
  • 9
  • 45
  • 54

I want to build a Python function that calculates,

alt text http://1.bp.blogspot.com/_mGF7Mo1o9b4/SlT2s9H7g_I/AAAAAAAAABE/RYgqR4C3XSM/s400/entropy

and would like to name my summation function Σ. In a similar fashion, would like to use Π for product, and so on. I was wondering if there was a way to name a python function in this fashion?

def Σ (..):
 ..
 ..

That is, does Python support unicode identifiers, and if so, could someone provide an example for it?

Thanks!


Original motivation for this was a piece of Clojure code I saw today that looks like,

(defn entropy [X]
 (* -1 (Σ [i X] (* (p i) (log (p i))))))

where Σ is a macro defined as,

(defmacro Σ
 ... )

and I thought that was pretty cool.


BTW, to address a couple of comments about readability - with a lot of stats/ML code for instance, being able to compose operations with symbols would be really helpful. (Especially for really complex integrals et al)

φ(z) = ∫(N(x|0,1,1), -∞, z)

vs

Phi(z) = integral(N(x|0,1,1), -inf, z)

or even just the lambda character for lambda()!

I want to build a Python function that calculates,

alt text http://1.bp.blogspot.com/_mGF7Mo1o9b4/SlT2s9H7g_I/AAAAAAAAABE/RYgqR4C3XSM/s400/entropy

and would like to name my summation function Σ. In a similar fashion, would like to use Π for product, and so on. I was wondering if there was a way to name a python function in this fashion?

def Σ (..):
 ..
 ..

That is, does Python support unicode identifiers, and if so, could someone provide an example for it?

Thanks!


Original motivation for this was a piece of Clojure code I saw today that looks like,

(defn entropy [X]
 (* -1 (Σ [i X] (* (p i) (log (p i))))))

where Σ is a macro defined as,

(defmacro Σ
 ... )

and I thought that was pretty cool.

I want to build a Python function that calculates,

alt text http://1.bp.blogspot.com/_mGF7Mo1o9b4/SlT2s9H7g_I/AAAAAAAAABE/RYgqR4C3XSM/s400/entropy

and would like to name my summation function Σ. In a similar fashion, would like to use Π for product, and so on. I was wondering if there was a way to name a python function in this fashion?

def Σ (..):
 ..
 ..

That is, does Python support unicode identifiers, and if so, could someone provide an example for it?

Thanks!


Original motivation for this was a piece of Clojure code I saw today that looks like,

(defn entropy [X]
 (* -1 (Σ [i X] (* (p i) (log (p i))))))

where Σ is a macro defined as,

(defmacro Σ
 ... )

and I thought that was pretty cool.


BTW, to address a couple of comments about readability - with a lot of stats/ML code for instance, being able to compose operations with symbols would be really helpful. (Especially for really complex integrals et al)

φ(z) = ∫(N(x|0,1,1), -∞, z)

vs

Phi(z) = integral(N(x|0,1,1), -inf, z)

or even just the lambda character for lambda()!

Source Link
viksit
  • 7.8k
  • 9
  • 45
  • 54

Unicode identifiers in Python?

I want to build a Python function that calculates,

alt text http://1.bp.blogspot.com/_mGF7Mo1o9b4/SlT2s9H7g_I/AAAAAAAAABE/RYgqR4C3XSM/s400/entropy

and would like to name my summation function Σ. In a similar fashion, would like to use Π for product, and so on. I was wondering if there was a way to name a python function in this fashion?

def Σ (..):
 ..
 ..

That is, does Python support unicode identifiers, and if so, could someone provide an example for it?

Thanks!


Original motivation for this was a piece of Clojure code I saw today that looks like,

(defn entropy [X]
 (* -1 (Σ [i X] (* (p i) (log (p i))))))

where Σ is a macro defined as,

(defmacro Σ
 ... )

and I thought that was pretty cool.

lang-py

AltStyle によって変換されたページ (->オリジナル) /