text:
# Basic Usage ¶

Feat handles continuous, categorical and boolean data types, as well as sequential (i.e. longitudinal) data. By default, FEAT will attempt to infer these data types automatically from the input data. The user may also specify types in the C++ API.

## Typical use case ¶

For traditional ML tasks, the user specifies data and trains an estimator like so:

python

from feat import Feat

#here's some random data
import numpy as np
X = np.random.rand(100,10)
y = np.random.rand(100)

est = Feat()
est.fit(X,y)

Note that, in python , as in sklearn, FEAT expects  X  to be an $$N \times D$$ numpy array, with $$N$$ samples and $$D$$ features.  y  should be 1d numpy array of length $$N$$ .

c++

#include "feat.h"
using FT::Feat;
#include <Eigen/Dense>

// feed in some data
Eigen::MatrixXd X(7,2);
X << 0,1,
0.47942554,0.87758256,
0.84147098,  0.54030231,
0.99749499,  0.0707372,
0.90929743, -0.41614684,
0.59847214, -0.80114362,
0.14112001,-0.9899925;
X.transposeInPlace();

Eigen::VectorXd y(7);
y << 3.0,  3.59159876,  3.30384889,  2.20720158,  0.57015434,
-1.20648656, -2.68773747;
// train
Feat est;
est.fit(X,y);

In c++ , FEAT expects  X  to be transposed, i.e., a $$D \times N$$ Eigen  MatrixXd  .  y  should be an Eigen  VectorXd  of length $$N$$ .

## Command line ¶

FEAT can learn from a  .csv  or  .tsv  file. In those cases, the target column must be labelled one of the following:

• class

• target

• label

To use tab-separated data, specify  -sep \\t  at the command line.

If you want to load your own data in a c++ script, you can use Feat’s built-in  load_csv  function.

#include "feat.h"
// variables
string dataset = "my_data.csv";
MatrixXd X;
VectorXd y;
vector<string> names;
vector<char> dtypes;
bool binary_endpoint=false; // true for binary classification
char delim = ',';   // assuming comma-separated file
// load the data
feat.set_feature_names(names);
feat.set_dtypes(dtypes);

Now  X  and  y  will have your data, and  feat  will know its types and the names of the variables.

## Longitudinal data ¶

Longitudinal data is handled by passing a file of longitudinal data with an identifier that associates each entry with a row of  X  . The longitudinal data should have the following format:

id

date

name

value

1

365

BloodPressure

128

Each measurement has a unique identifier (  id  ), an integer  date  , a string  name  , and a  value  .

The ids are used to associate rows of data with rows/samples in  X  . To do so, the user inputs a numpy array of the same length as  X  , where each value corresponds to the  id  value in the longitudinal data associated with that row of  X  .

For example,

zfile = 'longitudinal.csv'
ids = np.array([1, ...])
est.fit(X,y,zfile,ids)

This means that  id=1  associates all data in  Z  with the first row of  X  and  y  .

See here for an example.


text:
Tricki

## To prove that a sequence converges, find one or more convergent subsequences

### Quick description

To prove that a sequence converges, it is sometimes easier to start by finding a subsequence that converges (or proving that such a subsequence exists). Then one can hope to deduce that the sequence itself converges. Another way of using subsequences is to exploit the following result: if every subsequence has a further subsequence that converges to a limit , then the whole sequence converges to .

### Prerequisites

Basic concepts of real analysis.

 Incomplete This article is incomplete. Some general discussion would be nice, as would an example of the second method of proving convergence.

### Example 1

To prove that a Cauchy sequence of real numbers converges, assuming one of the other forms of the completeness axiom, one can argue as follows. First, one proves the Bolzano-Weierstrass theorem. Then one observes that a Cauchy sequence is bounded, and so by the Bolzano-Weierstrass theorem has a convergent subsequence. And finally, one proves that if a Cauchy sequence has a subsequence that tends to a limit , then the sequence itself tends to .

### Example 2

Here is a second way of proving that Cauchy sequences converge. Let be a Cauchy sequence. By the Cauchy condition we can choose a subsequence such that whenever . It follows that the closed intervals are nested, since if then , and . Therefore, their intersection is non-empty. Since their lengths tend to zero, the intersection is a singleton , and it is easy to check that the subsequence converges to . Therefore, since is Cauchy, so does the whole sequence.

### General discussion

The trick in the second approach was to replace a Cauchy sequence by a subsequence that was rapidly Cauchy. That gave us the inequality , which was crucial to the success of the proof.

format: plain


text:
J Syst Evol ›› 1994, Vol. 32 ›› Issue (6): 549-552.

• Research Articles •

The Discovery of Diploid Lycoris radiata (L′Her.) Herb. from Anhui

Shao Jian-zhang, Yang Ji-gao, Zhang Ding-cheng, Nie Liu-wang

• Published:1994-11-18

Abstract: Lycoris radiata (L′Her. ) Herb. containing wild and cultural types, is distributed in China and Japan. The karyotype variation in three populations of the species from Anhui is studied in this paper. (1) Wuhu wild population has a karyotype 2n=21+1B= 1m+12st +8t+1B. The chromosomes range in length from 7.50 to 14.10 µm with the ratio of the longest to the shortest 1.88. The karyotype belongs to Stebbins’(1971) 3A. (2) Huangshan wild population has two cytotypes: 2n=22 and 2n=22+1B. Type Ⅰ: The karyotype formula is 2n=22=12st+10t. The chromosomes range in length from 6.85 to 9.95 µm. with the ratio of the longest to the shortest 1.45. The karyotype belongs to 4A. Type Ⅱ: The karyotype formula is 2n=22+1B=6st+14t+2T+1B (plate 1: 7，8). The chromosomes range in length from 6.50 to 11.02 µm. with the ratio of the longest to the shortest 1.70. The karyotype belongs to 4A. (3) Wuhu cultural type has a karyotype 2n=33=30st +3t. The chromosomes range in length from 7.10 to 9.35 µm with the ratio of the longest to the shortest 1.32. The karyotype belongs to 4A. This result agrees well with the previous reports. The diploid types of Lycoris radiata (L´Her.) Herb. are found in Anhui for the firsttime.


text:
1. Complex variables - find an additional solution

This is not really a calculus question but I am taking a course in basic complex analysis and this is from the first chapter.

Show that the indicated numbers satisfy the given equation and find an additional solution, $z_2$.

$z^2+i=0, z_1=-\frac{\sqrt{2}}{2}+\frac{\sqrt{2}}{2}i$

Obviously you can plug $z_1$ in and get a true statement, but how do you go about finding an additional solution?

2. Re: Complex variables - find an additional solution

Do you recall synthetic or polynomial division? One way is to factor out $z - z_1$ from $z^2 + i$ and you will get a linear equation.

Edit: you don't even need to go this complicated: just use the fact that $z^2 + i$ is an even function, if z1 is a root, so is -z1.

3. Re: Complex variables - find an additional solution

Use the fact that complex zeros come in conjugate pairs. just conjugate z1 and call that z2, and plug it in and it also is a zero.

4. Re: Complex variables - find an additional solution

No, the above won't work because the polynomial does not have real coefficients.

5. Re: Complex variables - find an additional solution

Why won't the conjugate of z1 work? It is indeed a zero when I do plugged it in. Perhaps there is some theory I'm not seeing here, all the op's question asks is to find an additional solution. And so z1 conjugate is that solution.

6. Re: Complex variables - find an additional solution

No it isn't. Recheck your calculations.

The theory your not seeing here is that roots won't magically always be conjugate pairs. I could just create an arbitrary polynomial which clearly violates that rule, for example, by multiplying out the following:

$(z + i)(z + 2i)$

You are missing the fact that the coefficients of the polynomial have to be real in order for the roots to come in conjugate pairs.

The other root in this case is actually the negative of z1, not the conjugate.

7. Re: Complex variables - find an additional solution

We could probably just multiply z1 by e^(2kpi) for k in Z? Thanks sword for fixing my error, I didn't multiply correctly lol. Do you see an error with this new idea, using the fact that e^(2kpi)=1 is an identity.

8. Re: Complex variables - find an additional solution

Originally Posted by farzero
We could probably just multiply z1 by e^(2kpi) for k in Z? Thanks sword for fixing my error, I didn't multiply correctly lol. Do you see an error with this new idea, using the fact that e^(2kpi)=1 is an identity.
if it is an identity, this won't give you an additional answer.

look suppose $z_1$ is a root (any root) of $z^2 + c = 0$.

this means $z_1^2 + c = 0$.

therefore: $(-z_1)^2 + c = (-z_1)(-z_1) + c =$

$(-1)(z_1)(-1)(z_1) + c = (-1)(-1)z_1^2 + c = z_1^2 + c = 0$, that is: $-z_1$ is ALSO a root of $z^2 + c = 0$.

note that we discovered this without any information about "c".

9. Re: Complex variables - find an additional solution

Originally Posted by farzero
Why won't the conjugate of z1 work? It is indeed a zero when I do plugged it in. Perhaps there is some theory I'm not seeing here, all the op's question asks is to find an additional solution. And so z1 conjugate is that solution.
Again, you are completely wrong. $z_1= -\frac{\sqrt{2}}{2}+ \frac{\sqrt{2}}{2}i$. Its complex conjugate is $-\frac{\sqrt{2}}{2}- \frac{\sqrt{2}}{2}i$. The square is $\frac{2}{4}- 2\frac{2}{4}i- \frac{2}{4}= i$ so that if z is that complex conjugate, $z^2+ i= 2i$, not 0.

10. Re: Complex variables - find an additional solution

Yes, having already determined one root, the simplest way to find the other is "division". If you wished to solve $z^2+i= 0$ from the beginning, use polar form. This equation is the same as $z^2= -i$ and -i has modulus 1 and argument $3\pi/2$ (or $-\pi/4$). To find the square root, take the square root of the modulus (1) and divide the argument by 2: $(3\pi/2)/2= 3\pi/4$ so that one square root of -i is $cos(3\pi/4)+ i sin(3\pi/4)= -\frac{\sqrt{2}}{2}+ \frac{\sqrt{2}}{2}i$ which is the root we have.

Since adding " $2\pi$" to the argument does not change the number, we can also write $-i$ as modulus 1, argument $2\pi+ 3\pi/2= 7\pi/2$. That gives, as a second root, $cos(7\pi/4)+ i sin(7\pi/4)= \frac{\sqrt{2}}{2}-\frac{\sqrt{2}}{2}i$.

In other words, the second root is just the negative of the first root, just as you learned way back in basic algebra!

11. Re: Complex variables - find an additional solution

Thank you everyone for your input!

12. Re: Complex variables - find an additional solution

Originally Posted by Ragnarok
This is not really a calculus question but I am taking a course in basic complex analysis and this is from the first chapter.

Show that the indicated numbers satisfy the given equation and find an additional solution, $z_2$.

$z^2+i=0, z_1=-\frac{\sqrt{2}}{2}+\frac{\sqrt{2}}{2}i$

Obviously you can plug $z_1$ in and get a true statement, but how do you go about finding an additional solution?
$\text{if }z_1 \text{ and } z_2 \text{ are roots then we can write the polynomial as : }$

$(z-z_1)(z-z_2)=0 \Rightarrow \, \, z^2- z_1z-z_2z +z_1z_2 = 0 \, \Rightarrow \,\, z^2-(z_1+z_2)z +z_1z_2=0$

$\text{so comparing this to the original : }z_1+z_2 =0 \, \,\text{then }\fbox{ z_2=-z_1}$


text:
# Derivatives: Problems with Solutions

By Prof. Hernando Guzman Jaimes (University of Zulia - Maracaibo, Venezuela)
Problem 1
Let $f(x)$ be a real function such that $f:R\rightarrow R$. The derivative $f\prime (x)$ of $f(x)$ is given by the formula:
Problem 2
Find the derivative of $f(x)=x^3-12x$, using the formula above.
Problem 3
Find the derivative of $f(x)=\sqrt{x+4}$ using the formula from question 1.
Problem 4
What is the equation of the line tangent to the graph of
$f(x)=x^{2}+3x$ at the point $(-2,2)$. Graph it.
Problem 5
What is the equation of the tangent to the graph of

$f(x)=x^{2}+3x$ at $(-2,2)$.
Problem 6
What is the equation of the line tangent to the graph of $f(x)=x^{3}+2$
that is parallel to line $3x-y-4=0$.
Problem 7
What is the value of $f\prime (c)$ if $f(x)=x^{3}+2x^{2}-1$ and $c=-2$
Problem 8
What is the derivative of the function
$f(x)=\left\{ \begin{array}{c} x\quad \qquad x\leq 1 \\ x^{2}\quad \ \ \quad x>1 \end{array}\right\}$   at $x=0?$
Problem 9
What is the derivative of the function
$f(x)=\left\{ \begin{array}{c} x^{2}+1\quad \qquad x\leq 2 \\ 4x+3\quad \ \ \quad x>2 \end{array} \right\}$
at $x=3?$
Problem 10
What is the derivative of the function $f(t)=t^{3}+5t^{2}-3t+8$,
using derivative rules?

Problem 11
Consider the following functions and their derivatives:

$(i)\left\{ \begin{array}{c} f(x)=x^{2}+1\quad \\ f'(x)=2x\quad \ \end{array}\right\}$

$(ii)\left\{ \begin{array}{c} g(x)=\frac{x-1}{1-x}\quad \\ g'(x)=1\quad \ \end{array}\right\}$

$(iii)\left\{ \begin{array}{c} h(x)=\sqrt{x^{3}-x}\quad \\ h'(x)=\frac{3x^{2}-1}{2\sqrt{x^{3}-x}} \end{array} \right\}$
Problem 12
Consider the following functions and their derivatives:

$(i)\left\{ \begin{array}{c} f(x)=\sin (x^{3}-x+1)\quad \\ f'(x)=\cos (x^{3}-x+1)\quad \ \end{array}% \right\} \qquad (ii)\left\{ \begin{array}{c} g(x)=e^{x^{3}+x^{2}}\quad \\ g'(x)=\left( x^{3}+x^{2}\right) e^{x^{3}+x^{2}}\quad \ \end{array}\right\} \qquad$ $(iii)\qquad \left\{ \begin{array}{c} h(x)=\sqrt{\ln (x^{3}+1)}\quad \\ h'(x)=\frac{x^{3}+1}{2\sqrt{\ln (x^{3}+1)}}\quad \ \end{array} \right\}$
Problem 13
$f(x)=\frac{1}{x}-\sin (x^{2})$ and $g(x)=x^{2}+\cos (2x+1)$
Find $\frac{d}{dx}(f(x)+g(x)) =$
Problem 14
Given $f(x)=e^{x^{2}+x}$ and $g(x)=\sqrt{x^{2}-x+1}$
Find $\frac{d}{dx}(f(x)\cdot g(x))=$ ?
Problem 15
If $f(x)=\sqrt{2x^{3}-3x^{2}+5}$ and $g(x)=\ln (x^{2}-x+1)$,
find $\frac{d}{dx}(\frac{f(x)}{g(x)})=$
Problem 16
Find the value of $k$ such that the line $y=5x-4$ is tangent to the graph of the function $f(x)=x^{2}-kx$
Problem 17
Find the value of $k$ such that the line $y=4x-1$ is tangent to the graph of the function $f(x)=kx^{4}$
Problem 18
Graph $y=x^{2}$ and $y=-x^{2}+5$

Graph two tangent lines to $y=-x^{2}+5$ through the points of intersection of the both functions.
What are the equations of the tangents?
Problem 19
Let the function of the vertical position of an object in free fall be $s(t)=-16t^{2}+v_{0}t+s_{0}$ where $v_{0}:$ is initial object speed $s_{0}:$ initial position of the object.

If a coin is tossed from the top of a building that has a height of $1362ft$

a) Determine the functions for position and speed of the coin.
b) Calculate the average speed in the range $\left[ 1,2\right]$.
c) Find the instant speed when $t=1,t=2$
d) Calculate the time it takes for the coin to reach the floor.
e) Determine the speed when the coin reach the floor

Solve it by yourself and check the solution.
Problem 20
From a height of $200ft$ a ball is thrown down with initial speed of $-22ft/\sec$, if the function of the position is $s(t)=-16t^{2}+v_{0}t+s_{0}$ what is the velocity $V_{1}$ in third second?

What is the velocity $V_{2}$ after descending $108$ft?
Problem 21
A projectile is launched upwards from the earth's surface, with an initial velocity of $120m/s$, if the position function of the projectile is $s(t)=-4.9t^{2}+V_{0}t+s_{0}$, what is the velocity $V_{5}$ in $5$th second, and $V_{10}$ in $10$th second.

Correct:
Wrong:
Unsolved problems:
Contact email:


text:
# Thread: how to calculate the dot product ...

1. ## how to calculate the dot product ...

How to calculate the dot product of two big vectors in polar coordinate system?

2. Note that

$\mathbf{a}\cdot\mathbf{b}=ab\cos(\theta),$

where

$a=|\mathbf{a}|,\;b=|\mathbf{b}|,\;\text{and}\;\the ta$ is the angle between the two vectors. The RHS should be fairly straight-forward in polar coordinates.


text:
Logic for Computer Scientists/Predicate Logic/Semantic Trees

Semantic Trees

In this section we introduce the concept of semantic trees, which then can be used to proof completeness of resolution. For this we assume familiarity with the concepts of trees, binary trees and paths in trees.

Definition 15

A semantic tree for a set of clauses ${\displaystyle S}$ is a binary tree ${\displaystyle T}$ with root ${\displaystyle N_{0}}$, such that the edges are label with literals, built from elements from the Herbrand basis of ${\displaystyle S}$, such that:

• If ${\displaystyle N}$ is an inner node, its two outgoing edges are label with complementary literals ${\displaystyle A}$ and ${\displaystyle \lnot A}$.
• Every path to a node ${\displaystyle N}$ in ${\displaystyle T}$ does not contain complementary literals in ${\displaystyle I(N)}$, where ${\displaystyle I(N)}$ is the set of literals which are labels along the edges of the path.

Definition 16

A semantic tree is called complete, if every path contains every atom from the Herbrand basis either positive or negative.

Example: ${\displaystyle S=\{p(x),q(f(x))\}}$ with Herbrand basis

${\displaystyle \{p(a),q(a),p(f(a)),q(f(a)),p(f(f(a))),\ldots \}}$

Note, that for a semantic tree ${\displaystyle T}$ and a node ${\displaystyle N}$ the set ${\displaystyle I(N)}$ can be seen as an assignment of truth-values to ground atoms, as it is done in an Herbrand interpretation. Hence we call ${\displaystyle I(N)}$ a partial interpretation. A complete semantic tree corresponds to an exhaustive "enumeration" of interpretations.

Definition 17

• A node ${\displaystyle N}$ of a semantic tree ${\displaystyle T}$ is a failure node if ${\displaystyle I(N)}$ falsifies some ground instance of a clause in ${\displaystyle S}$, but ${\displaystyle I(N')}$ does not falsifiy any ground instance of a clause in ${\displaystyle S}$ for every ancestor node ${\displaystyle N'}$ of ${\displaystyle N}$.
• A semantic tree ${\displaystyle T}$ is called closed if every path contains a failure node.
• A node ${\displaystyle N}$ of a closed semantic tree is called an inference node, if both immediate descendant nodes are failure nodes.

Example: ${\displaystyle S=\{p(x),\lnot p(x)\lor q(f(x)),\lnot q(f(a))\}}$ with Herbrand basis

${\displaystyle \{p(a),q(a),p(f(a)),q(f(a)),p(f(f(a))),\ldots \}}$

Let ${\displaystyle T}$ be a complete semantic tree, than we call ${\displaystyle T'}$ the corresponding closed tree, if it is obtainable from ${\displaystyle T}$ by cutting all branches at a failure node.

Theorem 5 (Herbrand's Theorem - Version 1)

A set ${\displaystyle S}$ of clauses is unsatisfiable, iff for every complete semantic tree for ${\displaystyle S}$ there is a corresponding finite closed semantic tree.

Proof: Assume ${\displaystyle S}$ to be unsatisfiable and ${\displaystyle T}$ a complete semantic tree for ${\displaystyle S}$. For every path ${\displaystyle P}$ we have the set of labels ${\displaystyle I_{B}}$, which is an interpretation, because the tree is complete. Hence, ${\displaystyle I_{B}}$ falsifies a ground instance ${\displaystyle C'}$ of a clause ${\displaystyle C\in S}$, because ${\displaystyle S}$ is unsatisfiable. Since there are only finitely many literals in ${\displaystyle C'}$, there must be a failure node ${\displaystyle N_{B}}$ in a finite distance from the root. Since every path has such a failure node, there is a corresponding closed semantic tree ${\displaystyle T'}$, which is finite.

For the opposite direction, assume that for every complete semantic tree ${\displaystyle T}$ there is a finite closed corresponding tree ${\displaystyle T'}$. Then, every path contains a failure node, and hence, every interpretation falsifies ${\displaystyle S}$; hence ${\displaystyle S}$ is unsatisfiable.

Theorem 6 (Herbrand's Theorem - Version 2)

A set ${\displaystyle S}$ of clauses is unsatisfiable, iff there is a finite unsatisfiable set ${\displaystyle S'}$ of ground instances of clauses in ${\displaystyle S}$.

Proof: Assume ${\displaystyle S}$ to be unsatisfiable and ${\displaystyle T}$ a complete semantic tree for ${\displaystyle S}$. By Herbrand's theorem, version 1, there is a finite closed semantic tree ${\displaystyle T'}$ for ${\displaystyle S}$. Let ${\displaystyle S'}$ be the set of ground instances of clauses, which are falsified at all failure nodes of ${\displaystyle T'}$. ${\displaystyle S'}$ is finite and is falisified by every interpretation and hence unsatisfiable. The opposite direction we show by contraposition:

Note, that this version of Herbrand's theorem can be turned directly into a proof procedure: Given a set of clauses ${\displaystyle S}$, for which we want to proof unsatisfiability.

• Generate ${\displaystyle S_{1}',\ldots ,S_{n}',\ldots }$ sets of ground instances of clauses of ${\displaystyle S}$. Perform a propositional test for unsatisfiability on each of them.
• According to Herbrand's theorem, there is a finite ${\displaystyle S_{N}'}$ which is unsatisfiable, if ${\displaystyle S}$ is unsatisfiable.

Problems

Problem 10 (Predicate)

Assume the following set of clauses:

${\displaystyle M_{0}=\{\{p(x)\},\{q(x,f(x)),\lnot p(x)\},\{\lnot q(g(y),z)\}\}}$

1. Indicate (a) the Herbrand-universe and (b) the Herbrand-basis for ${\displaystyle M_{0}}$!
2. Give a closed semantic tree for ${\displaystyle M_{0}}$!

${\displaystyle \Box }$

Problem 11 (Predicate)

The following formulae ${\displaystyle F}$ and ${\displaystyle G}$ are given.

${\displaystyle F=\forall yp(y)\land \exists z\lnot p(z)}$

${\displaystyle G=r(a)\land \forall x(r(x)\to r(f(x)))}$

Give for ${\displaystyle F}$ and ${\displaystyle G}$ (a) a finate and (b) an infinite Herbrand model, or argument if this is not possible.
${\displaystyle \Box }$

Problem 12 (Predicate)

The following sets of clauses are given:

1. ${\displaystyle M_{1}={\big \{}\{p(a,x)\},\{\lnot p(y,b),q(y)\}{\big \}}}$
2. ${\displaystyle M_{2}={\big \{}\{r(x),r(f(x))\}{\big \}}}$

Give for each of them (a) a Herbrand universe, (b) Herbrand model and (c) a non-Herbrand model.
${\displaystyle \Box }$


text:
The Chauvenet criterion is a well-known criterion of selection and rejection of the data used by the Physics. It establishes that in an experiment is well to discard the data whose distance from the average is greater than a certain number of the delta.
In the stock market if prices move away from the average with a volatility too high are suspect. This principle is embodied in the Chauvenet floor with the definition of two asymptotes and two data areas rejection.
The Chauvenet Radius is the quadratic sum of the delta (distance from average) and sigmoid ( volatility ) and is therefore an obvious market stability index. In fact the moments when price strongly moves away from the average with high volatility coincide with the moments of high instability of the market.

It can be considered an evolution of John Bollinger method introduced during the '80.

```//@version=2
len=input(defval=20,minval=1)
price=close
avg=sma(price,len)
x=price-avg
y=stdev(price,len)


text:
### SAS Data Analysis Examples Multiple Regression Power Analysis

#### Introduction

Power analysis is the name given to the process for determining the sample size for a research study. The technical definition of power is that it is the probability of detecting a "true" effect when it exists. Many students think that there is a simple formula for determining sample size for every research situation. However, the reality it that there are many research situations that are so complex that they almost defy rational power analysis. In most cases, power analysis involves a number of simplifying assumptions, in order to make the problem tractable, and running the analyses numerous times with different variations to cover all of the contingencies.

In this unit we will try to illustrate how to do a power analysis for multiple regression model that has two control variables, one continuous research variable and one categorical research variable (three levels).

#### Description of the Experiment

A school district is designing a multiple regression study looking at the effect of gender, family income, mother's education and language spoken in the home on the English language proficiency scores of Latino high school students. The variables gender and family income are control variables and not of primary research interest. Mother's education is a continuous research variable that measures the number of years that the mother attended school. The range of this variable is expected to be from 4 to 20. The variable language spoken in the home is a categorical research variable with three levels: 1) Spanish only, 2) both Spanish and English, and 3) English only. Since there are three levels, it will take two dummy variables to code language spoken in the home.

The full regression model will look something like this,

engprof = b0 + b1(gender) + b2(income) + b3(momeduc) + b4(homelang1) + b5(homelang2)
Thus, the primary research hypotheses are the test of b3 and the joint test of b4 and b5. These tests are equivalent the testing the change in R2 when momeduc (or homelang1 & homelang2) are added last to the regression equation.

#### The Power Analysis

We will make use of the SAS proc power to do the power analysis. To begin with, we believe, from previous research, that the R2 for the full-model (r2f) with five predictor variables (2 control, 1 continuous research, and 2 dummy variables for the categorical variable) will be will be about 0.48.

Let's start with the continuous predictor (momeduc). We think that it will add about 0.03 to the R2 when it is added last to the model. This means that the R2 for the model without the variable (the reduced model) would be about 0.45, which leads to the difference in R2 (rsquarediff) of .03.  The total number of variables (nfullpredictors) is 5 and the number being tested (ntestpredictors) is one. We will run proc power for powers equal to .7, .8 and .9.

proc power;
multreg
model = fixed
nfullpredictors = 5
ntestpredictors = 1
rsquarefull = 0.48
rsquarediff = 0.03
ntotal = .
power = 0.7 to .9 by .1;
run;
The POWER Procedure
Type III F Test in Multiple Regression

Fixed Scenario Elements

Method                                       Exact
Model                                      Fixed X
Number of Predictors in Full Model               5
Number of Test Predictors                        1
R-square of Full Model                        0.48
Difference in R-square                        0.03
Alpha                                         0.05

Computed N Total

Nominal    Actual        N
Index      Power     Power    Total

1        0.7     0.704      110
2        0.8     0.803      139
3        0.9     0.901      185

This gives us a range of sample sizes ranging from 110 to 185 depending on power.

Let's see how this compares with the categorical predictor (homelang1 & homelang2) which uses two dummy variables in the model. We believe that the change in R2 attributed to the two dummy variables will be about 0.025. This would give an  R2 of 0.455. The nfullpredictors stays at 5 while the ntestpredictors is now 2.

proc power;
multreg
model = fixed
nfullpredictors = 5
ntestpredictors = 2
rsquarefull = 0.48
rsquarediff = 0.025
ntotal = .
power = 0.7 to .9 by .1;
run;
Type III F Test in Multiple Regression

Fixed Scenario Elements

Method                                       Exact
Model                                      Fixed X
Number of Predictors in Full Model               5
Number of Test Predictors                        2
R-square of Full Model                        0.48
Difference in R-square                       0.025
Alpha                                         0.05

Computed N Total

Nominal    Actual        N
Index      Power     Power    Total

1        0.7     0.702      164
2        0.8     0.801      204
3        0.9     0.901      267

This series of power analyses yielded sample sizes ranging from 164 to 267. These sample sizes are larger than those for the continuous research variable.

If it is the case that both of these research variables are important, we might want to take into that we are testing two separate hypotheses (one for the continuous and one for the categorical) by adjusting the alpha level. The simplest but most draconian method would be to use a bonferroni adjustment by dividing the nominal alpha level, 0.05, by the number of hypotheses, 2, yielding an alpha of 0.025. We will rerun the categorical variable power analysis using the new adjusted alpha level.

proc power;
multreg
model = fixed
nfullpredictors = 5
ntestpredictors = 2
rsquarefull = 0.48
rsquarediff = 0.025
ntotal = .
alpha = .025
power = 0.7 to .9 by .1;
run;
Type III F Test in Multiple Regression

Fixed Scenario Elements

Method                                       Exact
Model                                      Fixed X
Number of Predictors in Full Model               5
Number of Test Predictors                        2
Alpha                                        0.025
R-square of Full Model                        0.48
Difference in R-square                       0.025

Computed N Total

Nominal    Actual        N
Index      Power     Power    Total

1        0.7     0.700      199
2        0.8     0.800      243
3        0.9     0.900      311

The bonferroni adjustment assumes that the tests of the two hypotheses are independent which is, in fact, not the case. The squared correlation between the two sets of predictors is about .2 which is equivalent to a correlation of approximately .45. Using an internet applet to compute a bonferroni adjusted alpha taking into account the correlation gives us an adjusted alpha value of 0.034 to use in the power analysis.

proc power;
multreg
model = fixed
nfullpredictors = 5
ntestpredictors = 2
rsquarefull = 0.48
rsquarediff = 0.025
ntotal = .
alpha = .034
power = 0.7 to .9 by .1;
run;
Type III F Test in Multiple Regression

Fixed Scenario Elements

Method                                       Exact
Model                                      Fixed X
Number of Predictors in Full Model               5
Number of Test Predictors                        2
Alpha                                        0.034
R-square of Full Model                        0.48
Difference in R-square                       0.025

Computed N Total

Nominal    Actual        N
Index      Power     Power    Total

1        0.7     0.702      184
2        0.8     0.801      226
3        0.9     0.901      292

Based on the series of power analyses the school district has decided to collect data on a sample of about 226 students. This sample size should yield a power of around 0.8 in testing hypotheses concerning both the continuous research (momeduc) variable and the categorical research variable language spoken in the home (homelang1 & homelang2). The nominal alpha level is 0.05 but has been adjusted to .034 to take into account the number of hypotheses tested and the correlation between the predictors.

• Data Analysis Examples
• References
• Cohen, J. 1988. Statistical Power Analysis for the Behavioral Sciences, Second Edition. Mahwah, NJ: Lawrence Erlbaum Associates.

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.


text:
If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

# Comparing fractions with > and < symbols

CCSS.Math:

## Video transcript

When you write a fraction, there are actually words for the top number and the bottom number. And the words are a lot more fancy than the word "top number" and "bottom number." What mathematicians typically use is the word "numerator" for the top number and "denominator" for the bottom number. And what I want to do now that we know that the top number is the numerator of the fraction and the bottom number is the denominator, I want to compare pairs of fractions that have either the same denominator or the same numerator. So let's look at this first pair. I want to compare 4/7 to 3/7. And I have two wholes right over here. They're the same hole, and I've divided them into sevenths. I've divided them into 7 equal chunks. And I want to see what's larger, 4/7 or 3/7. So what I can do is, I can fill in 4/7. Let me select 4 out of the 7. So, that's 1, 2, 3, 4. And the fact that trying to even get to 4/7 I had to have 3/7 first gives you good clue that 4/7 is probably larger, or it is larger. But now let's color in 3/7, just so we can compare. So 1, 2, 3/7. And so it's pretty clear that on the left-hand side, we are shading in more of the whole than on the right-hand side. So, 4/7 represents a larger fraction, more of the whole than 3/7. And the way that we can state that comparison mathematically is with the greater than symbol. We can write 4/7 is greater than 3/7. Now, the greater than and less than symbols can sometimes be confusing. This is greater than. This is less than. And the way that I remember it is that the greater than symbol, either symbol, the small pointy side is always on the side of the smaller number, and the big open side is always on the side of the larger number. So here, big open side is opening towards the 4/7, small pointy side opening to the 3/7. 4/7 is greater than 3/7. Now, what about 3/7 and 3/4? So, here I have different denominators, but I have the same numerator. And so I encourage you to pause this video and draw maybe little boxes like this and try to judge for yourself which of these is a larger fraction, represents a larger number. Well, let's color them in. So, let's think about 3/7 first. And we actually already drew it here, but I can do it really fast right over here. So that is 3/7. I've colored in 3 of the 7 equal groups. And what would 3/4 be? Well, that's 1/3, 2/4, and 3/4. And so it's pretty clear that 3/4 represents a larger fraction of the whole, that 3/4 is larger, or that 3/7 is smaller. So we could write that 3/7 is less than 3/4. So, notice, same exact numerator. When I divided it-- because this fraction symbol could also be viewed as division. When I have it as more equal groups, so it's a fraction of more equal groups, so 3 out of 7 versus 3 out of 4, this is a smaller number, which which makes sense. Now, let's compare these two. We have the same denominator, different numerators-- 3/4 versus 2/4. Well, 3/4 we've already looked at. We can just shade in 3 of these. So 3 of these fourths. So that's 3/4 right over there. And then 2/4, well, we're going to only have 2 of the fourths, 1, 2. So 2/4 is clearly the smaller number. 3/4 is the greater number. So, once again, we could write 3/4 is greater than 2/4. And then finally, I encourage you to pause the video. Try to come up with whether 2/4 or 3/6 is a larger number. Well, let's color it in again. We've already seen 2/4. We just have to color in 2 of our fourths. So let's just color in 2 of our fourths right over there. And then 3/6, we've split our whole into 6 equal sections-- 1, 2, 3, 4, 5, 6. We need to color in 3 of them. And as you see, we're coloring in the exact same amount of the whole. These two fractions are equivalent. These are equivalent fractions. 2/4 is equal to 3/6. And as you see here, they're both filling in half of the whole. If we were to just draw the whole and split it only-- let me do this in a different color. If we have our whole, and we were to split it only into two sections, we are shading in exactly 1 out of the 2 sections. So you could say that 2/4 is equal to 3/6, and they both equal 1/2. So 1/2 is equal to 2/4 is equal to 3/6.


text:
# Algorithm for trimming b-spline

I'm stuck with developing algorithm to trim b-spline so it begins at certain point without changing it's shape. I'm using these formulas: link. I have already implemented inserting knot at given t. Let me show you example of what I'm trying to do.

Control points of my spline are: ((0, 0), (19, 0), (0, 12), (28, 38), (56, 14), (34, 0), (56, 0))
Knot vector of original spline is: (0, 0, 0, 0, 0,25, 0,5, 0,75, 1, 1, 1, 1)
Degree of spline: 3.

Now I would like add a knot at let's say 0.3 and then cut all that preceeds 0.3 without changing the shape of curve so it starts at inserted point.

-
You're supposed to be able to use the Cox-de Boor recursion for something like this (analogous to the use of the de Casteljau recursion to cut off Bézier curves). –  J. M. is back. Jul 17 '12 at 12:21

Suppose your spline curve is $C(t)$, and let $m$ denote its degree. You need to insert the knot $t = 0.3$ repeatedly until its multiplicity is $m$. So, in your example, this will give you a new curve whose knot sequence is $(0,0,0,0,0.25,0.3,0.3,0.3, 0.5, 0.75, 1,1,1,1)$. Let $Q_1,Q_2, \ldots, Q_n$ be the control points of this curve, in your example, $n$ will be equal to 10.
The point $C(0.3)$ will be a control point of the new refined curve; call it $Q_r$. This control point divides the list of control points into two halves. The first half of the curve will be defined by the control points $Q_1,Q_2, \ldots, Q_r$ and the second half will be defined by the control points $Q_r, \ldots, Q_n$. The first half will have knots $(0,0,0,0,0.25,0.3,0.3,0.3, 0.3)$, and the second half will have knots $(0.3, 0.3, 0.3, 0,3, 0.5, 0.75, 1,1,1,1)$. If you want to, you can normalise each of these knot sequences to the range $[0,1]$. For example, normalising the first half would give (0,0,0,0, 2.5/3, 1,1,1,1).


text:
The Lax pair for the mKdV hierarchy

Clarkson, Peter and Joshi, Nalini and Mazzocco, M. (2006) The Lax pair for the mKdV hierarchy. In: Delabaere, Eric and Loday-Richaud, Michele, eds. Théories Asymptotiques et Equations de Painlevé. Séminaires et Congrès (14). Sociètè Mathèematique de France, Paris, France, pp. 53-64. ISBN 978-2-85629-229-7. (The full text of this publication is not currently available from this repository. You may be able to access a copy if URLs are provided) (KAR id:3223)

 The full text of this publication is not currently available from this repository. You may be able to access a copy if URLs are provided.

Abstract

Rational solutions of the second, third and fourth Painlevé equations (-) can be expressed in terms of logarithmic derivatives of special polynomials that are defined through coupled second order, bilinear differential-difference equations which are equivalent to the Toda equation.

In this paper the structure of the roots of these special polynomials, and the special polynomials associated with algebraic solutions of the third and fifth Painlevé equations, is studied and it is shown that these have an intriguing, highly symmetric and regular structure. Further, using the Hamiltonian theory for -, it is shown that all these special polynomials, which are defined by differential-difference equations, also satisfy fourth order, bilinear ordinary differential equations.

Item Type: Book section Hamiltonians, Painlevé equations, rational solutions Q Science > QA Mathematics (inc Computing science) > QA299 Analysis, Calculus Divisions > Division of Computing, Engineering and Mathematical Sciences > School of Mathematics, Statistics and Actuarial Science Peter Clarkson 07 Jun 2008 11:54 UTC 16 Nov 2021 09:41 UTC https://kar.kent.ac.uk/id/eprint/3223 (The current URI for this page, for reference purposes) https://orcid.org/0000-0002-8777-5284


text:
# Formatting output for use in forums etc [duplicate]

If we take the (simple) example

x = 1;
y = 2;
z = 3;

x + y + z

we get the (complete screen) result when copying into a more basic interface, such as a web forum or text editor

In[1]:= x = 1;
y = 2;
z = 3;

In[4]:= x + y + z

Out[4]= 6

Is there any clever way to modify this output (preferably during the copy/paste operation) to become

x = 1;
y = 2;
z = 3;

x + y + z

> 6

(or some other 'minimalistic' output indicator than '>'), removing the input labels as well as reducing the output labels. It would be very convenient to have when pasting Mathematica code/output in web forums as well as in the verbatim environment in LaTeX. TIA.

• – Alexey Popkov Nov 5 '19 at 14:20

You can disable copying of the cell labels on the global level:

SetOptions[\$FrontEnd, {
"ExportTypesetOptions" -> {"PageWidth" -> 90, "IncludeCellLabels" -> False},
"ExportMultipleCellsOptions" -> {"IncludeCellLabels" -> False}}]

(I also set copied page width to be suitable for StackExchange).

This setting will persists between FrontEnd sessions.

As regards to prepending >  to the output expression (I would recommend prepending >      to have it formatted as code of the output), it can be achieved by low-level Notebook programming. Here is a start:

SetOptions[EvaluationNotebook[], CellEpilog :> Module[{out = NextCell[], boxes, newboxes},
If[CurrentValue[out, GeneratedCell],

Now any simple output will be prepended by >     .


text:
Maharashtra Board Class 8 Maths Solutions Chapter 3 Indices and Cube Root Practice Set 3.3

Maharashtra State Board Class 8 Maths Solutions Chapter 3 Indices and Cube Root Practice Set 3.3

Question 1.
Find the cube root of the following numbers.
i. 8000
ii. 729
iii. 343
iv. -512
v. -2744
vi. 32768
Solution:
i. 8000
= 2 × 2 × 2 × 10 × 10 × 10
= (2 × 10) × (2 × 10) × (2 × 10)
= (2 × 10)³
= 20³
∴ $$\sqrt[3]{8000}=20$$

ii. 729
= (3 × 3) × (3 × 3) × (3 × 3)
= (3 × 3)³
= 9³
∴ $$\sqrt[3]{729}=9$$

iii. 343
= 7 × 7 × 7
= 7³
∴ $$\sqrt[3]{343}=7$$

iv. -512
= 2 × 2 × 2 × 4 × 4 × 4
= (2 × 4) × (2 × 4) × (2 × 4)
= (2 × 4)³
= 8³
∴ – 512 = (- 8) × (- 8) × (- 8)
= (-8)³
∴ $$\sqrt[3]{-512}=-8$$

v. -2744
= 2 × 2 × 2 × 7 × 7 × 7
= (2 × 7) × (2 × 7) × (2 × 7)
= (2 × 7)³
= 14³
∴ -2744 = (-14) × (-14) × (-14)
= (-14)³
∴ $$\sqrt[3]{-2744}=-14$$

vi. 32768
= 2 × 2 × 2 × 4 × 4 × 4 × 4 × 4 × 4
= (2 × 4 × 4) × (2 × 4 × 4) × (2 × 4 × 4)
= (2 × 4 × 4)³
= 32³
∴ $$\sqrt[3]{32768}=32$$

Question 2.
Simplify:
i. $$\sqrt[3]{\frac{27}{125}}$$
ii. $$\sqrt[3]{\frac{16}{54}}$$
iii. If $$\sqrt[3]{729}=9$$ then $$\sqrt[3]{0.000729}$$ = ?
Solution:
i. $$\sqrt[3]{\frac{27}{125}}$$

ii. $$\sqrt[3]{\frac{16}{54}}$$

iii. $$\sqrt[3]{0.000729}$$

Note:
Here, number of decimal places in cube root = 6
∴ number of decimal places in cube of number = 2

Maharashtra Board Class 8 Maths Chapter 3 Indices and Cube Root Practice Set 3.3 Intext Questions and Activities

Question 1.
17 is a positive number. The cube of 17, which is 4913, is also a positive number. Cube of -6 is -216. Take some more positive and negative numbers and obtain their cubes. Find the relation between the sign of a number and the sign of its cube. (Textbook pg. no. 17)
Solution:
Consider, 6³ = 6 × 6 × 6 = 216 and (-4)³ = (- 4) × (- 4) × (- 4) = – 64
Thus, cube of a positive number is positive and cube of a negative number is negative.
∴ Sign of a number = sign of its cube.

Question 2.
In example 4 and 5 on textbook pg. no. 17, observe the number of decimal places in the number and number of decimal places in the cube of the number. Is there any relation between the two? (Textbook pg. no. 17)
Solution:
Yes, there is a relation between the number of decimal places in the number and its cube.
(1.2)³ = 1.728, (0.02)³ = 0.000008
No. of decimal places in 1.2 = 1
No. of decimal places in 1.728 = 3
No. of decimal places in 0.02 = 2
No. of decimal places in 0.000008 = 6
Thus, number of decimal places in cube of a number is three times the number of decimal places in that number.


text:
# Logic of mathematicsOne company produces androids of two types: those of type V,which always tell the truth, and those of

###### Question:

logic of mathematics One company produces androids of two types: those of type V, which always tell the truth, and those of type M, which always lie. Dr. Turing, a specialist in Artificial Intelligence, is examining a group of five androids - labeled Alpha, Beta, Gamma, Delta and Epsilon -, manufactured by this company, to determine how many of the five are type V. He asks Alpha: "Are you type M?" Alpha responds but Dr. Turing, distracted, does not hear the answer. The remaining androids then make the following statements: Beta: "Alpha answered yes". Range: "Beta is lying". Delta: "Gamma is lying". Epsilon: "Alpha is type M". Even without paying attention to Alpha's response, Dr. Turing could then correctly conclude that the number of type V androids in that group was equal to. to 1 b) 4 c) 3 d) 5 e) 2

#### Similar Solved Questions

##### Determine the strength of a lumber with a slope of the grain of 1:15. The P/Q is 0.15. Use n=1.5
Determine the strength of a lumber with a slope of the grain of 1:15. The P/Q is 0.15. Use n=1.5...
##### C Translate the statement in b into symbols (4 points) d_ Write the converse, inverse, and contrapositive of the statement in words points)b. If you buyldo healthy_banana_thenyou'Il be
C Translate the statement in b into symbols (4 points) d_ Write the converse, inverse, and contrapositive of the statement in words points) b. If you buyldo healthy_ banana_ then you'Il be...
##### I missed class and a classmate sent her notes over and I am confused on what the notes in purple ...
I missed class and a classmate sent her notes over and I am confused on what the notes in purple mean. General Chemistry II Module 6 Chapter 16: Aqueous lonic Equilibrium 16.2 Buffers: Solutions That Resist pH Change 1. What is a buffer? significant amounts of weak acids and its conjugate base. T...
SYNTHESIS 111...
##### Aaula HSO; EPO HCtHsO HF BCOOH KCHo HC Hso; HCO, HAA.O; HPO; HTeOs HBro NK; HCO; HTcOg HAsO} HCs HaOs HPO;22 2 1 10,32IZJSEum Qusstlon Uslns tk UJbla abo e Gant saloct th tp tolut 05 25mLolzomNaH- TcO;730100mL & L0M Hi SOt SOmLof LOMH TcOc sonLo:OMNo H TcOe
Aaula HSO; EPO HCtHsO HF BCOOH KCHo HC Hso; HCO, HAA.O; HPO; HTeOs HBro NK; HCO; HTcOg HAsO} HCs HaOs HPO; 22 2 1 10,32 IZJS Eum Qusstlon Uslns tk UJbla abo e Gant saloct th tp tolut 05 25mLolzomNaH- TcO; 730 100mL & L0M Hi SOt SOmLof LOMH TcOc sonLo:OMNo H TcOe...
##### Question 4 (1 point) What molecular technique would be the most appropriate for aalyzing the sizes of DNA fragments?PCRgel electrophoresisgene cloningDNA sequencingautomated DNA sequencing
Question 4 (1 point) What molecular technique would be the most appropriate for aalyzing the sizes of DNA fragments? PCR gel electrophoresis gene cloning DNA sequencing automated DNA sequencing...
Net income was $474,000. Issued common stock for$79,000 cash. Paid cash dividend of $15,000. Paid$100,000 cash to settle a note payable at its $100,000 maturity value. Paid$116,000 cash to acquire its treasury stock. Purchased equipment for $89,000 cash. Use the above information to determine th... 1 answer ##### Taking it to the Net A2 1 10 BTN 4-3 Access the SEC's EDGAR database (SEC.gov... Taking it to the Net A2 1 10 BTN 4-3 Access the SEC's EDGAR database (SEC.gov ) and obtain the March 21, 2017 filing of its fiscal 2017 10-K report (for year ended January 28, 2017) for J.Crew Group, Inc. (ticker: JCG). Required Prepare a table that reports the gross margin ratios for J.Crew usi... 1 answer ##### All parts 3. (a) Find a basis for (Q(75) over Q. (b) Find a basis for... all parts 3. (a) Find a basis for (Q(75) over Q. (b) Find a basis for Q(73, 77, 75) over Q(75). (c) What is (Q(V3, 77, 75): Q]?... 5 answers ##### Question No; Muks 253J+25Use Ihe deluton Hurd the slope ol the tangcnt t0 the cune/W= D *=} '-26) Find the firs[ derivalive of the parumetric cunveFind0 " =sin '()+ tan(secx) Find the slope ofthe nonmal line Ihe cun e 8 J'+3"+8e0 a the point (4,-2)Question No:Maksi 442+2+2Use logarithmic diflerentiation finid fS " t23 Evaluate"=(Inx)"Given tha velocily v() =48t , and the initial position of the body {(2124Find the body' posIlion$(t)H) Find the mini
Question No; Muks 253J+25 Use Ihe deluton Hurd the slope ol the tangcnt t0 the cune/W= D *=} '-2 6) Find the firs[ derivalive of the parumetric cunve Find 0 " =sin '()+ tan(secx) Find the slope ofthe nonmal line Ihe cun e 8 J'+3"+8e0 a the point (4,-2) Question No: Maksi 4...
##### Assume that both populations are normally distributed. a) Test whether 147 *H2 at the a=0.10 level...
Assume that both populations are normally distributed. a) Test whether 147 *H2 at the a=0.10 level of significance for the given sample data. b) Construct a 90% confidence interval about 17 - H2 Sample 1 18 19.1 5.1 Sample 18 20.3 4.8 Click the icon to view the Student t-distribution table. a) Perfo...
##### Point) Express the equation in exponential form (a) log4 2 = 2 That is, write your answer in the form AB =C ThenA=B=C=(b) log2 1 = -3. That is, write your answer in the form DE = F _ ThenD=E=F=
point) Express the equation in exponential form (a) log4 2 = 2 That is, write your answer in the form AB =C Then A= B= C= (b) log2 1 = -3. That is, write your answer in the form DE = F _ Then D= E= F=...
##### P+QExercise I: Compute the conjoin POQ ofthe two points P-(2,9) and Q-(3,10) on the elliptic curve with equation yl = x' + 73.Exercise 2: Suppose that P is a point on the curve y? = x' + 73. Explain why the reflection of P in the X-axis is another point on the curve_How do we conjoin a point to itself? One point P isn't enough to determine line ~there are lots of lines through P. But we can use a familiar calculus idea and replace the secant line with the tangent Iine in the compu
P+Q Exercise I: Compute the conjoin POQ ofthe two points P-(2,9) and Q-(3,10) on the elliptic curve with equation yl = x' + 73. Exercise 2: Suppose that P is a point on the curve y? = x' + 73. Explain why the reflection of P in the X-axis is another point on the curve_ How do we conjoin a ...
##### Performance Models are often used to visualize the three-dimensional shape of molecules. Using gumdrops as atoms and toothpicks to bond them together, construct models of different hydrocarbons. Use large gumdrops for carbon and smaller gumdrops for hydrogen.
Performance Models are often used to visualize the three-dimensional shape of molecules. Using gumdrops as atoms and toothpicks to bond them together, construct models of different hydrocarbons. Use large gumdrops for carbon and smaller gumdrops for hydrogen....
##### Y (m) (1 point) -3 -2 -1 1 2 x (m) Two point charges, A =-5...
y (m) (1 point) -3 -2 -1 1 2 x (m) Two point charges, A =-5 Q and B = 4Q, are located at the positions shown in the figure above. a) What is the force on a charge +q at the origin? jkQqN b) Where would you place a point charge +3.5 Q such that the net force on q is zero? (x, y) =(...
##### Inscribe right circular cylinder of height h and radius Sx in cone of fixed radius R and fixed height H: See the illustration Express the volume V of the cylinder as function of x (Hint: V = Irh Note also the similar triangles |Choose tho correct answor bulow25Hx V(x) =5x)*?V(x)e 25hxxV(x) =-25H= ( ' - 125H1 0 D. V(x) =
Inscribe right circular cylinder of height h and radius Sx in cone of fixed radius R and fixed height H: See the illustration Express the volume V of the cylinder as function of x (Hint: V = Irh Note also the similar triangles | Choose tho correct answor bulow 25Hx V(x) = 5x)*? V(x)e 25hxx V(x) = -2...
##### Question No 4(CLO - 2)(5+5-10)Find the sequence of this recurrence relation. an du-1 ~2an-2 + 5an-3 , where ao=5, a1-7,a2-9, and n is positive integer: What is the Initial value of n? 500 I Find 28(1-i) 6=20
Question No 4(CLO - 2) (5+5-10) Find the sequence of this recurrence relation. an du-1 ~2an-2 + 5an-3 , where ao=5, a1-7,a2-9, and n is positive integer: What is the Initial value of n? 500 I Find 28(1-i) 6=20...
##### 49. For moderate-intensity activity lasting LONGER than 2 hours and/or high intensity A. 1 hour B....
49. For moderate-intensity activity lasting LONGER than 2 hours and/or high intensity A. 1 hour B. 30 minutes C. 3 hours D. None of the above are correct 50. Client-centeredness and humility might look like saying, "Tell me about what's most imp True False 51 Appropriate regression means int...
##### Calculate f*f CLEAR SOLUTION PLEASEEE.... Thanks! 5. Calcule f * f si f(n)-S 1 si -...
Calculate f*f CLEAR SOLUTION PLEASEEE.... Thanks! 5. Calcule f * f si f(n)-S 1 si - Ž <rs f(x) = 0 otherwise Pleaseee I need the correct and Best answer for this problem! My class is Mathematical Method for Science... I Will rate this solution! CLEAR solution pleaseee! Thanks!...
##### A school teacher has a list of leftover school supplies from previous semesters. The teacher woul...
A school teacher has a list of leftover school supplies from previous semesters. The teacher would like to maintain an ordered list of the supplies. Write a program in C that reads in the data (a list of supplies in random order) from a file, orders the items by name, and writes the ordered list to ...
##### 0 Points) What is adsorption? Explain Freundlich and Langmuir adsorption isotherms Write the equations
0 Points) What is adsorption? Explain Freundlich and Langmuir adsorption isotherms Write the equations...
##### A survey of 25 randomly selected customers found the ages shown (in years): The mean is 32.48 years and the standard deviation is 9.66 years a) Construct a 98% confidence interval for the mean age of all customers , assuming that the assumptions and conditions for the confidence interval have been met b) How large is the margin of error? c) How would the confidence interval change if you had assumed that the standard deviation was known to be 10. years?41 33 332 43 24 20 36+ 37 35 27]4020 23
A survey of 25 randomly selected customers found the ages shown (in years): The mean is 32.48 years and the standard deviation is 9.66 years a) Construct a 98% confidence interval for the mean age of all customers , assuming that the assumptions and conditions for the confidence interval have been m...
##### The hydrogen atom, what is the total energy of an electron that is in an orbit that has a radius of 4.78 xl0-10 m? 1.51 ev
the hydrogen atom, what is the total energy of an electron that is in an orbit that has a radius of 4.78 xl0-10 m? 1.51 ev...
##### The decomposition ofNzOs NOz and Oz first order; with Tale conslani of 4.80 10 4Is at 459C. If the initial concentration of NzOs 4.79*10-2 molL, what is the concentration Of NzOs after 492 s? How long would take for the concentration ofNzOs decTe1sc 1,00 10-2 moll from an initial concentration of 4.79*10-2 moVL?moVLSubmitShow Tutor Stops
The decomposition ofNzOs NOz and Oz first order; with Tale conslani of 4.80 10 4Is at 459C. If the initial concentration of NzOs 4.79*10-2 molL, what is the concentration Of NzOs after 492 s? How long would take for the concentration ofNzOs decTe1sc 1,00 10-2 moll from an initial concentration of 4....
##### SYJBW &op sopads JsJ4} 184} SUOSEJJI J4} JJB 65u0p3o. 1o4Jo U! ^0.3 Jou JE4M 'UBwO U! Sop3ds quuopu? â‚¬6 JJE 3.134L S
SYJBW & op sopads JsJ4} 184} SUOSEJJI J4} JJB 65u0p3o. 1o4Jo U! ^0.3 Jou JE4M 'UBwO U! Sop3ds quuopu? â‚¬6 JJE 3.134L S...
##### Let X be the weights of newborn babies in pounds, and denote m to be its...
Let X be the weights of newborn babies in pounds, and denote m to be its median. For a sample of 14, we have: 5.2 11.8 7.1 14.4 6.3 7.5 11.1 5.5 9.8 12.7 10.5 10.9 8.7 9.2 (a) Give point estimates of 70.25, 0.35, M, 0.75 (b) Find the following confidence intervals and, from Table II in Appendix B, s...
##### How do you evaluate k(-6) given k(n)=n+2?
How do you evaluate k(-6) given k(n)=n+2#?...

-- 0.033769--


text:
# Display Fibonacci numbers

I just started coding programs with python. As a challenge I wanted to program something to print out the Fibonacci Numbers. It looks like I've done what I wanted to do (I checked the first few numbers) and because I just started coding, I obviously don't know if this is a legitimate code and somebody would code it like that. Keep in mind that I have only done some basic lessons in python so I just want to get some feedback and advice for better code.

def spiral(sequence):
numbers = []
for i in sequence:
numbers.append(0)
if i == 0 or i == 1:
numbers[i] = 1
continue
numbers[i] = numbers[i-1] + numbers[i-2]
return numbers
times = range(int(input("How many times do you want to go through? ")))
fibonacci = spiral(times)
print(fibonacci)

The way sequence is used guarantees that the results will be wrong for the majority of inputs. It's clearly intended that sequence should be a continuous range starting at 0. So rather than require the range as input, it would make more sense to require the limit as input.

        numbers.append(0)
if i == 0 or i == 1:
numbers[i] = 1
continue
numbers[i] = numbers[i-1] + numbers[i-2]

This confused me briefly until I figured out that it appends 0 as a placeholder and then overwrites it with the appropriate Fibonacci number. Following the principle of KISS (keep it simple), it would make more sense to append the Fibonacci number directly.

IMO the expression is short enough to use a ternary:

        numbers.append(numbers[i-1] + numbers[i-2] if i > 1 else 1)

Those two changes give

def spiral(n):
numbers = []
for i in range(n):
numbers.append(numbers[i-1] + numbers[i-2] if i > 1 else 1)
return numbers
times = int(input("How many times do you want to go through? "))
fibonacci = spiral(times)
print(fibonacci)

The names seem quite opaque. Why spiral? Why times? They both seem to assume some context which isn't documented in the code.

It would be more Pythonic to write a generator, but since you say you're a beginner this may be a concept which you haven't encountered yet.

• Thank you for the feedback. The names of the variables came from translating the variable names from my language to english, which wasn't very smart to make them in my language I know, but I had do think of names quick. Gonna work on the naming next time. :) – nookyi Jun 30 '18 at 12:44


text:
# cross product

This topic is 3715 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I've been using the crossproduct to calculate the normal vector for two given vectors in 3d space, which I calculate by doing: v × w = (vywz − wyvz, vzwx − wzvx, vxwy − wxvy ) I tried to see why this calculation results in a vector perpendicular to the plane v & w form, but can't figure out why that is. In 2D for 1 vector it is simple enough, you just switch (x,y) with (-y,x)to get a perpendicular vector. But I can't see why the crossproduct does this in 3d for two vectors... Could anyone explain me why? [Edited by - bitshit on October 13, 2007 1:48:29 PM]

##### Share on other sites
This is quite easy to show if you know that the dot product of two non-zero vectors is 0 if and only if they are perpendicular.

v * (v x w) = vxvywz - vxwyvz + vyvzwx − vywzvx + vzvxwy − vzwxvy = 0

##### Share on other sites
What you can do is plug the unknown output vector (x,y,z) into the top row of a 3x3 matrix, where the other two rows are the input vectors (vx,vy,vz) and (wx,wy,wz):
[  x  y  z ][ vx vy vz ][ wx wy wz ]

We know that the determinant of a matrix should be the hyper-volume of the parallelepiped formed by the vectors of that matrix. Since we want (x,y,z) to be perpendicular to the input vectors, the parallelepiped is going to look like a parallelogram that also has a height, with no sheering. Volume is base area times height. It just so happens that the length of the cross product is both the base area and the height, meaning that |(v x w)|2 = volume = determinant (the squared length of the cross product equals the determinant). If we expand the above determinant we get:

x(vywz - wyvz) + y(vzwx - vxwz) + z(vxwy - vywx) = determinant

Clearly, if we let x, y, and z equal their constant factors from the above equation, we satisfy all our conditions.

##### Share on other sites
Perhaps the easiest way is as follows.

if p = (1, 0, 0) and q = (0, 1, 0)

There are two candidates for the perpendicular to these two vectors, p ^ q, and we chose p ^ q = (0, 0, 1) not (0, 0, -1) by convention.

Note that this is the vx.wy of

(vy.wz − wy.vz, vz.wx − wz.vx, vx.wy − wx.vy)

Then if r = (0, 0, 1) you can similarly write down p ^ r, r ^ p. Reversed they are negated as the cross product is anti-symmetric. You should find they correspond to the other terms in the formula for v ^ w. The rest follows by linearity, i.e. because

(a ^ b) + (a ^ c) = a ^ (b + c)

and m(a ^ b) = (ma) ^ b

You can combine them to produce the full cross product.

##### Share on other sites
Thanks guys! The penny dropped :)

##### Share on other sites

This topic is 3715 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628714
• Total Posts
2984358

• 23
• 11
• 10
• 13
• 14


text:
# Example 19: Using JSON-LD¶

JSON-LD is described pretty well at https://json-ld.org/ and the specification can be found at https://json-ld.org/latest/json-ld/ .

The website https://json-ld.org/playground/ is also useful.

There are many reasons for working with JSON-LD. The major search engines such as Google require ecommerce companies to mark up their websites with a systematic description of their products and more and more companies use it as an easy serialization format to share data.

The benefit for your organization is that you can now combine your documents with graphs, graph search and graph algorithms. Normally when you store documents in a document store you set up your documents in such a way that it is optimized for direct retrieval queries. Doing complex joins for multiple types of documents or even doing a shortest path through a mass of object (types) is however very complicated. Storing JSON-LD objects in AllegroGraph gives you all the benefits of a document store and you can semantically link objects together, do complex joins and even graph search.

A second benefit is that, as an application developer, you do not have to learn the entire semantic technology stack, especially the part where developers have to create individual triples or edges. You can work with the JSON data serialization format that application developers usually prefer.

In the following you will first learn about JSON-LD as a syntax for semantic graphs. After that we will talk more about using JSON-LD with AllegroGraph as a document-graph-store.

## Setup¶

You can use Python 2.6+ or Python 3.3+. There are small setup differences which are noted. You do need agraph-python-101.0.1 or later.

Mimicking instructions in the Installation document, you should set up the virtualenv environment.

1. Create an environment named jsonld:

python3 -m venv jsonld

or:

python2  -m virtualenv jsonld

1. Activate it:

Using the Bash shell:

source jsonld/bin/activate

Using the C shell:

source jsonld/bin/activate.csh

1. Install agraph-python:

pip install agraph-python

And start python:

python
[various startup and copyright messages]
>>>

We assume you have an AllegroGraph 6.5.0 server running. We call ag_connect. Modify the host, port, user, and password in your call to their correct values:

from franz.openrdf.connect import ag_connect
with ag_connect('repo', host='localhost', port='10035',
user='test', password='xyzzy') as conn:
print (conn.size())

If the script runs successfully a new repository named repo will be created.

## JSON-LD setup¶

We next define some utility functions which are somewhat different from what we have used before in order to work better with JSON-LD. createdb() creates and opens a new repository and opendb() opens an existing repo (modify the values of host, port, user, and password arguments in the definitions if necessary). Both return repository connections which can be used to perform repository operations. showtriples() displays triples in a repository.

import os
import json, requests, copy

from franz.openrdf.sail.allegrographserver import AllegroGraphServer
from franz.openrdf.connect import ag_connect
from franz.openrdf.vocabulary.xmlschema import XMLSchema
from franz.openrdf.rio.rdfformat import RDFFormat

# Functions to create/open a repo and return a RepositoryConnection
# Modify the values of HOST, PORT, USER, and PASSWORD if necessary

def createdb(name):

def opendb(name):

def showtriples(limit=100):
statements = conn.getStatements(limit=limit)
with statements:
for statement in statements:
print(statement)

Finally we call our createdb function to create a repository and return a RepositoryConnection to it:

conn=createdb('jsonplay')

## Some Examples of Using JSON-LD¶

In the following we try things out with some JSON-LD objects that are defined in json-ld playground: jsonld

The first object we will create is an event dict. Although it is a Python dict, it is also valid JSON notation. (But note that not all Python dictionaries are valid JSON. For example, JSON uses null where Python would use None and there is no magic to automatically handle that.) This object has one key called @context which specifies how to translate keys and values into predicates and objects. The following @context says that every time you see ical: it should be replaced by http://www.w3.org/2002/12/cal/ical#, xsd: by http://www.w3.org/2001/XMLSchema#, and that if you see ical:dtstart as a key than the value should be treated as an xsd:dateTime.

event = {
"@context": {
"ical": "http://www.w3.org/2002/12/cal/ical#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"ical:dtstart": { "@type": "xsd:dateTime" }
},
"ical:summary": "Lady Gaga Concert",
"ical:location": "New Orleans Arena, New Orleans, Louisiana, USA",
"ical:dtstart": "2011-04-09T20:00:00Z"
}

Let us try it out (the subjects are blank nodes so you will see different values):

>>> conn.addData(event)
>>> showtriples()
(_:b197D2E01x1, <http://www.w3.org/2002/12/cal/ical#summary>, "Lady Gaga Concert")
(_:b197D2E01x1, <http://www.w3.org/2002/12/cal/ical#location>, "New Orleans Arena, New Orleans, Louisiana, USA")
(_:b197D2E01x1, <http://www.w3.org/2002/12/cal/ical#dtstart>, "2011-04-09T20:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>)

### Adding an @id and @type to Objects¶

In the above we see that the JSON-LD was correctly translated into triples but there are two immediate problems: first each subject is a blank node, the use of which is problematic when linking across repositories; and second, the object does not have an RDF type. We solve these problems by adding an @id to provide an IRI as the subject and adding a @type for the object (those are at the lines just after the @context definition):

>>> event = {
"@context": {
"ical": "http://www.w3.org/2002/12/cal/ical#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"ical:dtstart": { "@type": "xsd:dateTime" }
},
"@id": "ical:event-1",
"@type": "ical:Event",
"ical:summary": "Lady Gaga Concert",
"ical:location": "New Orleans Arena, New Orleans, Louisiana, USA",
"ical:dtstart": "2011-04-09T20:00:00Z"
}

We also create a test function to test our JSON-LD objects. It is more powerful than needed right now (here we just need conn,addData(event) and showTriples() but test will be useful in most later examples. Note the allow_external_references=True argument to addData(). Again, not needed in this example but later examples use external contexts and so this argument is required for those.

def test(object,json_ld_context=None,rdf_context=None,maxPrint=100,conn=conn):
conn.clear()
showtriples(limit=maxPrint)

Here we apply test to event:

>>> test(event)
(<http://www.w3.org/2002/12/cal/ical#event-1>, <http://www.w3.org/2002/12/cal/ical#summary>, "Lady Gaga Concert")
(<http://www.w3.org/2002/12/cal/ical#event-1>, <http://www.w3.org/2002/12/cal/ical#location>, "New Orleans Arena, New Orleans, Louisiana, USA")
(<http://www.w3.org/2002/12/cal/ical#event-1>, <http://www.w3.org/2002/12/cal/ical#dtstart>, "2011-04-09T20:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>)
(<http://www.w3.org/2002/12/cal/ical#event-1>, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://www.w3.org/2002/12/cal/ical#Event>)

Note in the above that we now have a proper subject and a type.

### Referencing a External Context Via a URL¶

The next object we add to AllegroGraph is a person object. This time the @context is not specified as a JSON object but as a link to a context that is stored at http://schema.org/. Also in the definition of the function test above we had this parameter in addData: allow_external_references=True. Requiring that argument explicitly is a security feature. One should use external references only that context at that URL is trusted (as it is in this case).

person = {
"@context": "http://schema.org/",
"@type": "Person",
"@id": "foaf:person-1",
"name": "Jane Doe",
"jobTitle": "Professor",
"telephone": "(425) 123-4567",
"url": "http://www.janedoe.com"
}

Here is the output:

>>> test(person)
(<http://xmlns.com/foaf/0.1/person-1>, <http://schema.org/name>, "Jane Doe")
(<http://xmlns.com/foaf/0.1/person-1>, <http://schema.org/jobTitle>, "Professor")
(<http://xmlns.com/foaf/0.1/person-1>, <http://schema.org/telephone>, "(425) 123-4567")
(<http://xmlns.com/foaf/0.1/person-1>, <http://schema.org/url>, <http://www.janedoe.com>)
(<http://xmlns.com/foaf/0.1/person-1>, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://schema.org/Person>)

### Improving Performance by Adding Lists¶

Adding one person at a time requires doing an interaction with the server for each person. It is much more efficient to add lists of objects all at once rather than one at a time. Note that addData will take a list of dicts and still do the right thing. So let us add a 1000 persons at the same time, each person being a copy of the above person but with a different @id. (The example code is repeated below for ease of copying.):

>>> x = [copy.deepcopy(person) for i in range(1000)]
>>> len(x)
1000
>>> c = 0
>>> for el in x:
el['@id']= "http://franz.com/person-" + str(c)
c= c + 1
>>> test(x,maxPrint=10)
(<http://franz.com/person-0>, <http://schema.org/name>, "Jane Doe")
(<http://franz.com/person-0>, <http://schema.org/jobTitle>, "Professor")
(<http://franz.com/person-0>, <http://schema.org/telephone>, "(425) 123-4567")
(<http://franz.com/person-0>, <http://schema.org/url>, <http://www.janedoe.com>)
(<http://franz.com/person-0>, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://schema.org/Person>)
(<http://franz.com/person-1>, <http://schema.org/name>, "Jane Doe")
(<http://franz.com/person-1>, <http://schema.org/jobTitle>, "Professor")
(<http://franz.com/person-1>, <http://schema.org/telephone>, "(425) 123-4567")
(<http://franz.com/person-1>, <http://schema.org/url>, <http://www.janedoe.com>)
(<http://franz.com/person-1>, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://schema.org/Person>)
>>> conn.size()
5000
>>>

Here is the code run for copying.

x = [copy.deepcopy(person) for i in range(1000)]
len(x)

c = 0
for el in x:
el['@id']= "http://franz.com/person-" + str(c)
c= c + 1

test(x,maxPrint=10)

conn.size()

### Adding a Context Directly to an Object¶

You can download a context directly in Python, modify it and then add it to the object you want to store. As an illustration we load a person context from json-ld.org (actually a fragment of the schema.org context) and insert it in a person object. (We have broken and truncated some output lines for clarity and all the code executed is repeated below for ease of copying.):

>>> context=requests.get("https://json-ld.org/contexts/person.jsonld").json()['@context']
>>> context
{'Person': 'http://xmlns.com/foaf/0.1/Person',
'xsd': 'http://www.w3.org/2001/XMLSchema#',
'name': 'http://xmlns.com/foaf/0.1/name',
'jobTitle': 'http://xmlns.com/foaf/0.1/title',
'telephone': 'http://schema.org/telephone',
'nickname': 'http://xmlns.com/foaf/0.1/nick',
'affiliation': 'http://schema.org/affiliation',
'depiction': {'@id': 'http://xmlns.com/foaf/0.1/depiction', '@type': '@id'},
'image': {'@id': 'http://xmlns.com/foaf/0.1/img', '@type': '@id'},
'born': {'@id': 'http://schema.org/birthDate', '@type': 'xsd:date'},
...}
>>> person = {
"@context": context,
"@type": "Person",
"@id": "foaf:person-1",
"name": "Jane Doe",
"jobTitle": "Professor",
"telephone": "(425) 123-4567",
}
>>> test(person)
(<http://xmlns.com/foaf/0.1/person-1>, <http://xmlns.com/foaf/0.1/name>, "Jane Doe")
(<http://xmlns.com/foaf/0.1/person-1>, <http://xmlns.com/foaf/0.1/title>, "Professor")
(<http://xmlns.com/foaf/0.1/person-1>, <http://schema.org/telephone>, "(425) 123-4567")
(<http://xmlns.com/foaf/0.1/person-1>,
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>,
<http://xmlns.com/foaf/0.1/Person>)
>>>

Here is the code run for copying.

context=requests.get("https://json-ld.org/contexts/person.jsonld").json()['@context']
# The next produces lots of output, uncomment if desired
#context

person = {
"@context": context,
"@type": "Person",
"@id": "foaf:person-1",
"name": "Jane Doe",
"jobTitle": "Professor",
"telephone": "(425) 123-4567",
}
test(person)

### Building a Graph of Objects¶

We start by forcing a key’s value to be stored as a resource. We saw above that we could specify the value of a key to be a date using the xsd:dateTime specification. We now do it again for foaf:birthdate. Then we created several linked objects and show the connections using Gruff.

context = { "foaf:child": {"@type":"@id"},
"foaf:brotherOf": {"@type":"@id"},
"foaf:birthdate": {"@type":"xsd:dateTime"}}

p1 = {
"@context": context,
"@type":"foaf:Person",
"@id":"foaf:person-1",
"foaf:birthdate": "1958-04-09T20:00:00Z",
"foaf:child": ['foaf:person-2', 'foaf:person-3']
}

p2 = {
"@context": context,
"@type":"foaf:Person",
"@id":"foaf:person-2",
"foaf:brotherOf": "foaf:person-3",
"foaf:birthdate": "1992-04-09T20:00:00Z",
}

p3 = {"@context": context,
"@type":"foaf:Person",
"@id":"foaf:person-3",
"foaf:birthdate": "1994-04-09T20:00:00Z",
}

test([p1,p2,p3])

Here is the output:

>>> test([p1,p2,p3])
(<http://xmlns.com/foaf/0.1/person-1>, <http://xmlns.com/foaf/0.1/birthdate>, "1958-04-09T20:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>)
(<http://xmlns.com/foaf/0.1/person-1>, <http://xmlns.com/foaf/0.1/child>, <http://xmlns.com/foaf/0.1/person-2>)
(<http://xmlns.com/foaf/0.1/person-1>, <http://xmlns.com/foaf/0.1/child>, <http://xmlns.com/foaf/0.1/person-3>)
(<http://xmlns.com/foaf/0.1/person-1>, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://xmlns.com/foaf/0.1/Person>)
(<http://xmlns.com/foaf/0.1/person-2>, <http://xmlns.com/foaf/0.1/brotherOf>, <http://xmlns.com/foaf/0.1/person-3>)
(<http://xmlns.com/foaf/0.1/person-2>, <http://xmlns.com/foaf/0.1/birthdate>, "1992-04-09T20:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>)
(<http://xmlns.com/foaf/0.1/person-2>, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://xmlns.com/foaf/0.1/Person>)
(<http://xmlns.com/foaf/0.1/person-3>, <http://xmlns.com/foaf/0.1/birthdate>, "1994-04-09T20:00:00Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>)
(<http://xmlns.com/foaf/0.1/person-3>, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, <http://xmlns.com/foaf/0.1/Person>)

The following shows the graph that we created in Gruff. Note that this is what JSON-LD is all about: connecting objects together.

### JSON-LD Keyword Directives can be Added at any Level¶

Here is an example from the wild. The URL https://www.ulta.com/antioxidant-facial-oil?productId=xlsImpprod18731241 goes to a web page advertising a facial oil. (We make no claims or recommendations about this product. We are simply showing how JSON-LD appears in many places.) Look at the source of the page and you’ll find a JSON-LD object similar to the following. Note that @ directives go to any level. We added an @id key.

hippieoil = {"@context":"http://schema.org",
"@type":"Product",
"@id":"http://franz.com/hippieoil",
"aggregateRating":
{"@type":"AggregateRating",
"ratingValue":4.6,
"reviewCount":73},
"description":"""Make peace with your inner hippie while hydrating & protecting against photoaging....Mad Hippie's preservative-free Antioxidant Facial Oil is truly the most natural way to moisturize.""",
"name":"Antioxidant Facial Oil",
"image":"https://images.ulta.com/is/image/Ulta/2530018",
"productID":"2530018",
"offers":
{"@type":"Offer",
"availability":"http://schema.org/InStock",
"price":"24.99",
"priceCurrency":"USD"}}

test(hippieoil)

### JSON-LD @graphs¶

One can put one or more JSON-LD objects in an RDF named graph. This means that the fourth element of each triple generated from a JSON-LD object will have the specified graph name. Let’s show in an example.

context = {
"name": "http://schema.org/name",
"description": "http://schema.org/description",
"image": {
"@id": "http://schema.org/image", "@type": "@id" },
"geo": "http://schema.org/geo",
"latitude": {
"@id": "http://schema.org/latitude", "@type": "xsd:float" },
"longitude": {
"@id": "http://schema.org/longitude",  "@type": "xsd:float" },
"xsd": "http://www.w3.org/2001/XMLSchema#"
}

place = {
"@context": context,
"@id": "http://franz.com/place1",
"@graph": {
"@id": "http://franz.com/place1",
"@type": "http://franz.com/Place",
"name": "The Empire State Building",
"description": "The Empire State Building is a 102-story landmark in New York City.",
"image": "http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg",
"geo": {
"latitude": "40.75",
"longitude": "73.98" }
}}

and here is the result:

>>> test(place, maxPrint=3)
(<http://franz.com/place1>, <http://schema.org/name>, "The Empire State Building", <http://franz.com/place1>)
(<http://franz.com/place1>, <http://schema.org/description>, "The Empire State Building is a 102-story landmark in New York City.", <http://franz.com/place1>)
(<http://franz.com/place1>, <http://schema.org/image>, <http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg>, <http://franz.com/place1>)
>>>

Note that the fourth element (graph) of each of the triples is <http://franz.com/place1>. If you don’t add the @id the triples will be put in the default graph.

Here a slightly more complex example:

library = {
"@context": {
"dc": "http://purl.org/dc/elements/1.1/",
"ex": "http://example.org/vocab#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"ex:contains": {
"@type": "@id"
}
},
"@id": "http://franz.com/mygraph1",
"@graph": [
{
"@id": "http://example.org/library",
"@type": "ex:Library",
"ex:contains": "http://example.org/library/the-republic"
},
{
"@id": "http://example.org/library/the-republic",
"@type": "ex:Book",
"dc:creator": "Plato",
"dc:title": "The Republic",
"ex:contains": "http://example.org/library/the-republic#introduction"
},
{
"@id": "http://example.org/library/the-republic#introduction",
"@type": "ex:Chapter",
"dc:description": "An introductory chapter on The Republic.",
"dc:title": "The Introduction"
}
]
}

With the result:

>>> test(library, maxPrint=3)
(<http://example.org/library>, <http://example.org/vocab#contains>,
<http://example.org/library/the-republic>,
<http://franz.com/mygraph1>) (<http://example.org/library>,
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>,
<http://example.org/vocab#Library>, <http://franz.com/mygraph1>)
(<http://example.org/library/the-republic>,
<http://purl.org/dc/elements/1.1/creator>, "Plato",<http://franz.com/mygraph1>)
>>>

### JSON-LD as a Document Store¶

So far we have treated JSON-LD as a syntax to create triples. Now let us look at the way we can start using AllegroGraph as a combination of a document store and graph database at the same time. And also keep in mind that we want to do it in such a way that you as a Python developer can add documents such as dictionaries and also retrieve values or documents as dictionaries.

### Setup¶

The Python source file jsonld_tutorial_helper.py contains various definitions useful for the remainder of this example. Once it is downloaded, do the following (after adding the path to the filename):

conn=createdb("docugraph")
from jsonld_tutorial_helper import *

Let’s use our event structure again and see how we can store this JSON document in the store as a document. Note that the addData call includes the keyword: json_ld_store_source=True.

event = {
"@context": {
"@id": "ical:event1",
"@type": "ical:Event",
"ical": "http://www.w3.org/2002/12/cal/ical#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"ical:dtstart": { "@type": "xsd:dateTime" }
},
"ical:summary": "Lady Gaga Concert",
"ical:location":
"New Orleans Arena, New Orleans, Louisiana, USA",
"ical:dtstart": "2011-04-09T20:00:00Z"
}

Here is the output:

>>> conn.addData(event, allow_external_references=True,json_ld_store_source=True)

The jsonld_tutorial_helper.py file defines the function store as simple wrapper around addData that always saves the JSON source. For experimentation reasons it also has a parameter fresh to clear out the repository first.

>>> store(conn,event, fresh=True)

If we look at the triples in Gruff we see that the JSON source is stored as well, on the root (top-level @id) of the JSON object.

For the following part of the tutorial we want a little bit more data in our repository so please look at the helper file jsonld_tutorial_helper.py where you will see that at the end we have a dictionary named obs with about 9 diverse objects, mostly borrowed from the json-ld.org site: a person, an event, a place, a recipe, a group of persons, a product, and our hippieoil.

First let us store all the objects in a fresh repository. Then we check the size of the repo. Finally, we create a freetext index for the JSON sources.

>>> store(conn,[v for k,v in obs.items()], fresh=True)
>>> conn.size()
86
>>>

### Retrieving values with SPARQL¶

To simply retrieve values in objects but not the objects themselves, regular SPARQL queries will suffice. But because we want to make sure that Python developers only need to deal with regular Python structures as lists and dictionaries, we created a simple wrapper around SPARQL (see helper file). The name of the wrapper is runSparql.

Here is an example. Let us find all the roots (top-level @ids) of objects and their types. Some objects do not have roots, so None stands for a blank node.

>>> pprint(runSparql(conn,"select ?s ?type { ?s a ?type }"))
[{'s': 'cocktail1', 'type': 'Cocktail'},
{'s': None, 'type': 'Individual'},
{'s': None, 'type': 'Vehicle'},
{'s': 'tesla', 'type': 'Offering'},
{'s': 'place1', 'type': 'Place'},
{'s': None, 'type': 'Offer'},
{'s': None, 'type': 'AggregateRating'},
{'s': 'hippieoil', 'type': 'Product'},
{'s': 'person-3', 'type': 'Person'},
{'s': 'person-2', 'type': 'Person'},
{'s': 'person-1', 'type': 'Person'},
{'s': 'person-1000', 'type': 'Person'},
{'s': 'event1', 'type': 'Event'}]
>>>

We do not see the full URIs for ?s and ?type. You can see them by adding an appropriate format argument to runSparql, but the default is terse.

>>> pprint(runSparql(conn,"select ?s ?type { ?s a ?type } limit 2",format='ntriples'))
[{'s': '<http://franz.com/cocktail1>', 'type': '<http://franz.com/Cocktail>'},
{'s': None, 'type': '<http://purl.org/goodrelations/v1#Individual>'}]
>>>

### Retrieving a Dictionary or Object¶

retrieve is another function defined (in jsonld_tutorial_helper.py) for this tutorial. It is a wrapper around SPARQL to help extract objects. Here we see how we can use it. The sole purpose of retrieve is to retrieve the JSON-LD/dictionary based on a SPARQL pattern.

>>> retrieve(conn,"{?this a ical:Event}")
[{'@type': 'ical:Event', 'ical:location': 'New Orleans Arena, New Orleans, Louisiana, USA', 'ical:summary': 'Lady Gaga Concert', '@id': 'ical:event1', '@context': {'xsd': 'http://www.w3.org/2001/XMLSchema#', 'ical': 'http://www.w3.org/2002/12/cal/ical#', 'ical:dtstart': {'@type': 'xsd:dateTime'}}, 'ical:dtstart': '2011-04-09T20:00:00Z'}]
>>>

Ok, for a final fun (if you like expensive cars) example: Let us find a thing that is “fast and furious”, that is worth more than \$80,000 and that we can pay for in cash:

>>> addNamespace(conn,"gr","http://purl.org/goodrelations/v1#")
>>> x = retrieve(conn, """{ ?this fti:match 'fast furious*';
gr:acceptedPaymentMethods gr:Cash ;
gr:hasPriceSpecification ?price .
?price gr:hasCurrencyValue ?value ;
gr:hasCurrency "USD" .
filter ( ?value > 80000.0 ) }""")
>>> pprint(x)
[{'@context': {'foaf': 'http://xmlns.com/foaf/0.1/',
'foaf:page': {'@type': '@id'},
'gr': 'http://purl.org/goodrelations/v1#',
'gr:acceptedPaymentMethods': {'@type': '@id'},
'gr:hasCurrencyValue': {'@type': 'xsd:float'},
'pto': 'http://www.productontology.org/id/',
'xsd': 'http://www.w3.org/2001/XMLSchema#'},
'@id': 'http://example.org/cars/for-sale#tesla',
'@type': 'gr:Offering',
'gr:acceptedPaymentMethods': 'gr:Cash',
'gr:description': 'Need to sell fast and furiously',


text:
# nLab Dongmin Gang

Selected writings

## Selected writings

Discussion of the volume conjecture by combining the 3d-3d correspondence with AdS/CFT for background of M5-branes wrapped on hyperbolic 3-manifolds:

Enhanced to a defect field theory:

relation to Reidemeister torsion:

category: people

Last revised on June 1, 2020 at 18:09:52. See the history of this page for a list of all contributions to it.


text:
# Which statements about comparing fractions are correct?

Select all that apply.

A.
When two fractions have the same denominator, the fraction with the greater numerator is greater.

B.
When two fractions have the same numerator, the fraction with the greater denominator is greater.

C.
When two fractions have the same denominator and the same numerator, the two fractions are equal.

D.
When two fractions have the same numerator, the fraction with the lesser denominator is greater.

E.
When the denominator of a fraction is greater than the numerator, the fraction is greater than 1.

1. 👍
2. 👎
3. 👁
4. ℹ
5. 🚩
1. larger denominator means you cut it into more pieces.
larger numerator means you have more of those pieces.

1. 👍
2. 👎
3. ℹ
4. 🚩
👤
oobleck
2. When comparing fractions with the same denominator?

1. 👍
2. 👎
3. ℹ
4. 🚩
3. help me with thatFind all the fractions that match the statement.
Fractions less than
Question content area bottom
Part 1
Select all that apply.
A.
B.
C.
D.
E.
F.

1. 👍
2. 👎
3. ℹ
4. 🚩