KL divergence of two independent variables

enter image description here

I’m missing something obviously this is the way to start this:

$ \sum_{x\in X}^{}p(x)log(p(x)) – \sum_{x\in X}^{}p(x)log(q(x))$

how to continue from here?

It looks intuitive that if the variables are independent then the sum of all the partial variables ($ p_{1},…,p_{i}$ ) expression will be equal to the KL divergence. Is my intuition ok? How can it be shown in a mathematical way?

How to restrict the use of variables to the notebook?

I am solving two problems simultaneously in which the variable x is defined. To the left of the image, i’m solving shape functions and matrix operations. But to the right i’m solving Green’s function.

Notice the ‘x’ variable values are being used from left notebook to the right notebook which yields wrong solution.

But even when I open a new notebook the variable is carried over and being used.To the left I'm doing shape function calculations, To the right I'm evaluating the Green's function

To this i’ve tried doing this

Format -> Option Inspector -> Cell Options -> Evaluation Options

There I changed “CellContext” from “Global” to “Notebook”. But It is still using it as global variable.

How do I restrict the usage such that when I define a variable it is used within that notebook only?

Are type variables really only used in mathematical conversation about types?

Are type variables really only used in mathematical conversation about types? i.e. are type variables (meta-variables that only contain the type classification label) only exist in proofs for types but not in real programming languages? At least is this true for monomorphic types? i.e. I can’t actually define:

$ $ \texttt{ let id x = x }: \tau$ $

unless the type $ \tau$ has already been defined or is built in? i.e. type variables only exist for symbolic manipulation of type proofs for humans (at least for monomorphism).


Extra thoughts:

I am trying to understand how one defines the identity function $ \texttt{let id x = x}$ in monomorphic type systems. I believe the motivation for polymorphism is to allow to apply the same syntactic definition of a function to different data types that are NOT the same, like: $ \texttt{id 2}$ and $ \texttt{id true}$ without the type checker freaking out at us when it tries to run those (if the language is dynamically typed…I guess in static the compiler would complain at the first instance of the identity function being applied to the wrong type when we try to compile it to usable code).

So to my understanding, if we define types as a set of possible data values, so say $ \texttt{int}$ defines the set of all integers. Then the set $ Set_{int \to int}$ is the set of all functions that can map integers to integers. But if we have $ Set_{\forall \alpha . \alpha \to \alpha}$ and we consider the identity function corresponding to both sets so $ id_{\forall \alpha . \alpha \to \alpha} \in Set_{\forall \alpha . \alpha \to \alpha}$ and $ id_{int} \in Set_{int \to int}$ then when both identity functions are applied to integers they will behave exactly the same BUT they are not the same function (because they are not the same data value, the data value for one is identity on only integers while the other is give me any type and I will act like its corresponding identity. So in particular $ Set_{\alpha \to \alpha} = Set_{int \to int} \cup \dots \cup Set_{string \to string}$ (i.e. the identity $ id_{\alpha \to \alpha}$ is just the identity function for a specific type but not actually a function that is able to process ANY type, its one and in this case this is why the for all is important).

So my question is, is $ id_{\forall \alpha . \alpha \to \alpha} \in Set_{\alpha \to \alpha}$ ? I guess I am trying to clarify the dots … What does it cover? Perhaps it depends on the context of how the types are formally defined? If the $ \alpha$ stands for type variables, but type variables are only allowed to be monomorphic by definition (i.e. say the type constructor for the meta-langauge is recursive but only in the monomorphism where we can’t introduce the forall quantifier) then the $ id_{\forall \alpha . \alpha \to \alpha} \not\in Set_{\alpha \to \alpha}$ . But if the recursive definition for polymorphic types is recursive at the polymorphic step then perhaps $ id_{\forall \alpha . \alpha \to \alpha} \in Set_{\alpha \to \alpha}$ is true? Actually I don’t think so…


Context: CS 421


Related:

  • What does $ \forall \alpha_1, \dots , \alpha_n . \tau $ mean formally as a type?

  • What is the difference between $ \alpha \to \alpha $ vs $ \forall \alpha. \alpha \to \alpha$ ?

How to distribute values evenly when having several independent variables?

I am doing a research study with teens. Previously, I have already recruited and studied, let’s say, 11 teens (with various ages, gender, and ethnicity). Additionally, I am planning to recruit 10 teens. However, I need to try to go for diversity which means I need to distribute those 10 participants I want to recruit more or less evenly considering their gender, age, and ethnicity and based on the teens I have already studied. Is there any statistical methods that I can apply in this case?

Context-free grammar how to have same number of variables within a language

I am trying to get a CFG for the language:

the set A of odd-length strings in {a,b}^* whose first, middle and last symbols are all the same 

(some example of correct answers would be: a, aaa, ababa, aababba, some incorrect answers include: ɛ, aaaa, abbaa)

This is what I’ve done so far:

S=a|b|aTaTa|bTbTb T=aT|bT|ɛ 

However the problem is, I need T to be a string of any combination of ‘a’s and ‘b’s but of the same length, but I’m not sure how to express this. As you can see above, I can get strings made up of any combination, but they won’t be the same length when passed to S. Any help is appreciated!

Rendimiento Variables Tipo Tabla Vs Tablas Temporales

Estoy en un proceso de calculo de datos; pero necesito saber que es más optimo con respecto a las Variables tipo Tabla vs Tablas Temporales, donde se maneja en varias operaciones de Join, MAX, SUM, entre otras y se maneja más de 9 millones de registros por empresa, donde puede ser más de 10 empresas. En este momento tengo implementado variables tipo tablas con indices como el siguiente.

DECLARE @tbVhiObjFacturas AS TABLE(         emp_codigo INT INDEX IX_VHI_OBJ_FACTURAS NONCLUSTERED (can_codigo, ven_codigo),         can_codigo VARCHAR(8),         ven_codigo VARCHAR(16),         vhi_numero_factura VARCHAR(50),         ove_valor FLOAT     ) 

De igual forma saber en que casos debo utilizar las variables tipo Tabla, y en que casos tablas temporales.

Muchas gracias.

Variables de clases utilizadas en funciones – Python (Ayuda)

He empezado un proyecto en Udemy de Python, más concretamente el Milestone Project 2, en este, se utilizan muchas clases y funciones, pero hay una cosa particularmente que me cuesta entender. ¿Por qué cuando define una variable dentro de una clase la llama desde una función? Sería algo así como se muestra en el ejemplo de abajo:

> class Example: >  > def __init__(self): >  > self.value = 0 >  >  >  > def example(some_variable): >  > print(some_variable.value) 

¿Cómo es esto posible? Gracias y disculpad por la ignorancia, tal vez, he sido yo que no lo he entendido bien.

Codigo completo aquí