Skip to content

Commit 624e9ed

Browse files
author
aryan
committed
added Plotly.js to generate graphs
1 parent 85591d7 commit 624e9ed

8 files changed

Lines changed: 335 additions & 32 deletions

File tree

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
---
2+
title: Week 4 Statistics Graded Assignment Questions
3+
weight: 12
4+
tags:
5+
- statistics
6+
categories:
7+
- Statistics Graded Assignment
8+
series:
9+
- Statistics Graded Assignment
10+
---
11+
12+
### Questions (1)–(6): Based on Table 4.1.G
13+
14+
| Dealer's Location | OnePlus | BBK Electronics |
15+
| :-- | :-- | :-- |
16+
| Chennai | a | b |
17+
| Punjab | c | d |
18+
| Chennai | e | f |
19+
| Punjab | g | h |
20+
| Chennai | i | j |
21+
| Punjab | k | l |
22+
| Chennai | m | n |
23+
24+
#### 1. What is the population standard deviation of sales of OnePlus? (Enter the answer correct to 2 decimal accuracy)
25+
26+
{{< math/calc3 a=10 b=5 c=3 d=5 e=5 f=5 g=5 h=5 i=5 j=5 k=5 l=5 m=5 n=5 formula="a+b+c+d+e+f+g+h+i+j+k+l+m+n / 2" >}}
27+
28+
**Solution:**
29+
Let $m_x$ and $\sigma_x$ be the mean and population standard deviation of sales of OnePlus respectively.
30+
31+
$$
32+
m_x = \frac{a+c+e+g+i+k+m}{7}
33+
$$
34+
35+
$$
36+
\sigma_x^2 = \frac{(a - m_x)^2 + (c - m_x)^2 + (e - m_x)^2 + (g - m_x)^2 + (i - m_x)^2 + (k - m_x)^2 + (m - m_x)^2}{7}
37+
$$
38+
39+
Therefore, Population standard deviation of sales of OnePlus = $\sqrt{\sigma_x^2}$
40+
41+
{{< math/calc3 a=10 b=5 formula="a + b * 2" >}}
42+
43+
{{< math/calc3 x=2 y=3 z=4 formula="x * y + z" >}}
44+
45+
---
46+
47+
#### 2. What is the sample standard deviation of sales of BBK Electronics? (Enter the answer correct to 2 decimal accuracy)
48+
49+
**Solution:**
50+
Let $m_y$ and $S_y$ be the mean and sample standard deviation of sales of BBK Electronics respectively.
51+
52+
$$
53+
m_y = \frac{b+d+f+h+j+l+n}{7}
54+
$$
55+
56+
$$
57+
S_y^2 = \frac{(b - m_y)^2 + (d - m_y)^2 + (f - m_y)^2 + (h - m_y)^2 + (j - m_y)^2 + (l - m_y)^2 + (n - m_y)^2}{7-1}
58+
$$
59+
60+
Therefore, Standard deviation of sales of BBK Electronics = $\sqrt{S_y^2}$
61+
62+
---
63+
64+
#### 3. What is the sample co-variance between the sales of OnePlus and BBK Electronics? (Enter the answer correct to 2 decimal accuracy)
65+
66+
**Solution:**
67+
Let $X$ = Sales of OnePlus
68+
$Y$ = Sales of BBK Electronics.
69+
70+
$$
71+
Cov(X,Y) = \frac{\sum_{i=1}^{7}(x_i - m_x)(y_i - m_y)}{7-1}
72+
$$
73+
74+
$$
75+
= \frac{(a - m_x)(b - m_y) + (c - m_x)(d - m_y) + (e - m_x)(f - m_y) + (g - m_x)(h - m_y) + (i - m_x)(j - m_y) + (k - m_x)(l - m_y) + (m - m_x)(n - m_y)}{6}
76+
$$
77+
78+
---
79+
80+
#### 4. What is the correlation coefficient between the sales of OnePlus and BBK Electronics? (Enter the answer correct to 2 decimal accuracy)
81+
82+
**Solution:**
83+
Let $r$ be the correlation coefficient between the sales of OnePlus and BBK Electronics.
84+
85+
$$
86+
r = \frac{Cov(X,Y)}{S_x \times S_y}
87+
$$
88+
89+
where,
90+
Cov(X,Y) = Sample Covariance between sales of OnePlus and BBK Electronics.
91+
$S_x$ = Sample standard deviation of sales of OnePlus = $\sqrt{\frac{n}{n-1}} \sigma_x$ = $\sqrt{\frac{7}{6}} \sigma_x$
92+
$S_y$ = Sample standard deviation of sales of BBK Electronics.
93+
94+
---
95+
96+
#### 5. What can you say about the linear relationship between the sales of OnePlus and BBK Electronics? (More than one option can be correct)
97+
98+
(a) Strong
99+
(b) Positive
100+
(c) Weak
101+
(d) Negative
102+
(e) Absence of linear relationship
103+
(f) Moderate
104+
105+
**Solution:**
106+
107+
- If $0.75 \leq r \leq 1$, then there is a strong and positive linear relationship.
108+
- If $0.5 < r < 0.75$, then there is a moderate and positive linear relationship.
109+
- If $0.25 < r < 0.5$, then there is a weak and positive linear relationship.
110+
- If $-0.25 < r < 0.25$, then there is absence of linear relationship.
111+
- If $-0.5 < r < -0.25$, then there is a weak and negative linear relationship.
112+
- If $-0.75 < r < -0.5$, then there is a moderate and negative linear relationship.
113+
- If $-1 < r < -0.75$, then there is a strong and negative linear relationship.
114+
115+
---
116+
117+
#### 6. Is the sales of OnePlus strongly influenced by the location of dealer?
118+
119+
(a) Yes
120+
(b) No
121+
122+
**Solution:**
123+
Let Chennai be represented by 0 and Punjab by 1.
124+
The Point Bi-serial correlation coefficient between the sales of OnePlus and the location of dealer is given by:
125+
126+
$$
127+
r_{pb} = \frac{(\bar{Y_0} - \bar{Y_1})}{\sigma_x} \times \sqrt{p_0 \times p_1}
128+
$$
129+
130+
where,
131+
$p_0$ = Proportion of Chennai dealers = $\frac{4}{7}$
132+
$p_1$ = Proportion of Punjab dealers = $\frac{3}{7}$
133+
$\bar{Y_0}$ = Mean sales of OnePlus in Chennai = $\frac{a+e+i+m}{4}$
134+
$\bar{Y_1}$ = Mean sales of OnePlus in Punjab = $\frac{c+g+k}{3}$
135+
$\sigma_x$ = Population standard deviation of sales of OnePlus
136+
137+
$$
138+
r_{pb} = \frac{(\bar{Y_0} - \bar{Y_1})}{\sigma_x} \times 0.49487
139+
$$
140+
141+
If $0.75 \leq |r_{pb}| \leq 1$, then the sales of OnePlus is strongly influenced by the location of dealer.
142+
Else, the sales of OnePlus is not strongly influenced by the location of dealer.
143+
144+
---
145+
146+
### Questions (7)–(11): Based on Table 4.2.G
147+
148+
| Economic Conditions | Bright | Average | Dull | Borderline |
149+
| :-- | :-- | :-- | :-- | :-- |
150+
| Good | a | b | c | d |
151+
| Poor | e | f | g | h |
152+
153+
#### 7. What proportion of total students are dull? (Enter the answer correct to 2 decimal accuracy)
154+
155+
**Solution:**
156+
Proportion of dull students = $\frac{c+g}{a+b+c+d+e+f+g+h}$
157+
158+
---
159+
160+
#### 8. What proportion of total students are poor economic conditions? (Enter the answer correct to 2 decimal accuracy)
161+
162+
**Solution:**
163+
Proportion of students having poor economic conditions = $\frac{e+f+g+h}{a+b+c+d+e+f+g+h}$
164+
165+
---
166+
167+
#### 9. What proportion of students of good economic conditions are borderline? (Enter the answer correct to 2 decimal accuracy)
168+
169+
**Solution:**
170+
Required proportion = $\frac{d}{a+b+c+d}$
171+
172+
---
173+
174+
#### 10. What percentage of bright students are in poor economic conditions? (Enter the answer correct to 2 decimal accuracy)
175+
176+
**Solution:**
177+
Required percentage = $(\frac{e}{a+e}) \times 100$
178+
179+
---
180+
181+
#### 11. What percentage of average students are in good economic conditions? (Enter the answer correct to 2 decimal accuracy)
182+
183+
**Solution:**
184+
Required percentage = $(\frac{b}{b+f}) \times 100$
185+
186+
---

content/notes/iit-madras/data-science-and-application/foundational-level/mathematics/week 1/aq1.11.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,19 @@ Which of the following is true?
115115

116116
The image also provides context stating: "The domain and range of the function that is shown in Figure 1 are [m, x] and [n, y] respectively, where m, n, x, y ∈ ℝ."
117117

118-
{{< math/geogebra id="azbxfs9y" width="600" height="600" >}}
118+
{{< math/geogebra id="azbxfs9y" width="600" height="300" >}}
119+
120+
{{< plotly formula="Math.sin(x)" xmin="-6.28" xmax="6.28" step="0.05" title="y = sin(x)" xlabel="x" ylabel="y" >}}
121+
122+
{{< plotly formula="x^2-5" xmin="-6.28" xmax="6.28" step="0.05" title="y = sin(x)" xlabel="x" ylabel="y" >}}
123+
124+
{{< plotly formula="(Math.pow(x,2)) - 5" xmin="-6.28" xmax="6.28" step="0.05" title="y = sin(x)" xlabel="x" ylabel="y" >}}
125+
126+
{{< math/geogebra id="fe9vckwu" width="600" height="300" >}}
127+
128+
{{< math/geogebra id="qm9mevaj" width="400" height="300" >}}
129+
130+
{{< plotly formula="x*x + 2*x + 1" xmin="-10" xmax="10" step="0.1" title="Quadratic: y = x² + 2x + 1" xlabel="x" ylabel="y" >}}
119131

120132
A coordinate graph (Figure 1) is shown with several plotted points including (0, 9), (-4, 2), (3, 1), and (9, 6), suggesting there may be additional questions related to this graph that would follow this context.
121133

content/notes/iit-madras/data-science-and-application/foundational-level/mathematics/week 3/aq3.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ excludeSearch: false
88
weight: 31.5
99
---
1010

11+
{{< math/geogebra id="rbjh4eef" width="600" height="300" >}}
1112

1213
{{< border >}}
1314
**Question 1:** Which of the graphs in Figure 1 represents the following function: $y = x^2 - x + 1$?

layouts/partials/question-cards.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ <h3>
3737

3838
<style>
3939
.question-card {
40-
border: 3px solid #e0e0e0;
40+
border: 2px solid #e0e0e0;
4141
border-radius: 8px;
4242
padding: 20px;
43-
background: #fff;
43+
44+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
4445
}
4546
.question-card h3 {
4647
margin: 0;
Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,70 @@
11
<!-- filepath: d:\Code\hextra-notes\layouts\shortcodes\math\geogebra.html -->
22
{{ $materialID := .Get "id" | default "" }}
3-
{{ $width := .Get "width" | default "800" }}
3+
{{ $width := .Get "width" | default "800" }}
44
{{ $height := .Get "height" | default "600" }}
55
{{ $aspect := div (float $height) (float $width) | mul 100 }}
66

7-
{{ $sfsb := .Get "sfsb" | default "true" }}
8-
{{ $smb := .Get "smb" | default "false" }}
9-
{{ $stb := .Get "stb" | default "false" }}
10-
{{ $ai := .Get "ai" | default "false" }}
11-
{{ $sdz := .Get "sdz" | default "false" }}
7+
{{/* Engable Right Click, Zomming and Keboard Editing */}}
8+
{{ $rc := .Get "rc" | default "false"}}
9+
{{/* Show the Algebra Input Bar. */}}
10+
{{ $ai := .Get "ai" | default "false" }}
11+
{{/* Enable Shoft-Drag & Zoom */}}
12+
{{ $sdz := .Get "sdz" | default "false" }}
13+
{{/* Show the GeoGebra Menu Bar. */}}
14+
{{ $smb := .Get "smb" | default "false" }}
15+
{{/* Show the GeoGebra Toolbar. */}}
16+
{{ $stb := .Get "stb" | default "false" }}
17+
{{/* Show Toolbar Help */}}
18+
{{ $stbh := .Get "stbh" | default "false" }}
19+
{{/* Allow label dragging */}}
20+
{{ $Id := .Get "Id" | default "false" }}
21+
{{/* Show Reset icon (top-right) */}}
22+
{{ $sri := .Get "sri" | default "false" }}
23+
{{/* Show play button that starts the construction */}}
24+
{{ $ctl := .Get "ctl" | default "false" }}
25+
26+
27+
{{/* Show full-screen button. Make sure you alse add allowfullscreen to the iframe tag. */}}
28+
{{ $sfsb := .Get "sfsb" | default "false" }}
29+
{{/* Show zoom buttons */}}
30+
{{ $szb := .Get "szb" | default "false" }}
31+
1232
{{ $sfbl := .Get "sfbl" | default "false" }}
13-
{{ $sri := .Get "sri" | default "false" }}
1433

15-
{{ if not $materialID }}
16-
<p class="error">GeoGebra material ID is required.</p>
17-
{{ return }}
18-
{{ end }}
34+
{{ if not $materialID }}
35+
<p class="error">GeoGebra material ID is required.</p>
36+
{{ return }} {{ end }}
1937

2038
<div class="ggb-responsive-container" style="--aspect:{{ $aspect }}%;">
2139
<iframe
22-
src="https://www.geogebra.org/material/iframe/id/{{ $materialID }}/width/{{ $width }}/height/{{ $height }}/border/888888/sfsb/{{ $sfsb }}/smb/{{ $smb }}/stb/{{ $stb }}/ai/{{ $ai }}/sdz/{{ $sdz }}/sfbl/{{ $sfbl }}/sri/{{ $sri }}"
40+
src="https://www.geogebra.org/material/iframe/id/{{ $materialID }}/width/{{ $width }}/height/{{ $height }}/border/888888/rc/{{ $rc }}/szb/{{ $szb }}/ctl/{{ $ctl }}/Id/{{ $Id }}/stbh/{{ $stbh }}/sfsb/{{ $sfsb }}/smb/{{ $smb }}/stb/{{ $stb }}/ai/{{ $ai }}/sdz/{{ $sdz }}/sfbl/{{ $sfbl }}/sri/{{ $sri }}"
2341
allowfullscreen
2442
loading="lazy"
43+
style="border: 1px solid #e4e4e4; border-radius: 4px"
2544
></iframe>
2645
</div>
2746

2847
<style>
29-
.ggb-responsive-container {
30-
position: relative;
31-
width: 100%;
32-
padding-top: var(--aspect, 75%);
33-
max-width: 900px;
34-
margin: 1em auto;
35-
}
36-
.ggb-responsive-container iframe {
37-
position: absolute;
38-
top: 0; left: 0;
39-
width: 100%;
40-
height: 100%;
41-
border: 0;
42-
display: block;
43-
}
48+
.ggb-responsive-container {
49+
position: relative;
50+
width: 100%;
51+
padding-top: var(--aspect, 75%);
52+
max-width: 900px;
53+
margin: 1em auto;
54+
border: 1px solid #e4e4e4;
55+
border-radius: 4px;
56+
}
57+
.ggb-responsive-container iframe {
58+
position: absolute;
59+
top: 0;
60+
left: 0;
61+
width: 100%;
62+
height: 100%;
63+
border: 0;
64+
display: block;
65+
object-fit: cover;
66+
}
4467
</style>
4568

46-
{{/* {{< math/geogebra id="abcd1234" width="700" height="500" sfsb="false" smb="true" stb="true" ai="true" sdz="false" sfbl="true" >}} */}}
69+
{{/* {{< math/geogebra id="abcd1234" width="700" height="500" sfsb="false"
70+
smb="true" stb="true" ai="true" sdz="false" sfbl="true" >}} */}}

layouts/shortcodes/math/graph.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!-- filepath: d:\Code\hextra-notes\layouts\shortcodes\plotly.html -->
2+
{{ $id := printf "plotly_%d" now.UnixNano }}
3+
{{ $formula := .Get "formula" | default "Math.sin(x)" }}
4+
{{ $xmin := .Get "xmin" | default "-10" }}
5+
{{ $xmax := .Get "xmax" | default "10" }}
6+
{{ $step := .Get "step" | default "0.1" }}
7+
{{ $title := .Get "title" | default "Plotly Graph" }}
8+
{{ $xlabel := .Get "xlabel" | default "x" }}
9+
{{ $ylabel := .Get "ylabel" | default "y" }}
10+
11+
<div id="{{ $id }}" style="width:100%;max-width:600px;height:400px;"></div>
12+
<script src="https://cdn.plot.ly/plotly-2.32.0.min.js"></script>
13+
<script>
14+
(function() {
15+
var x = [];
16+
var y = [];
17+
for (var i = Number({{ $xmin }}); i <= Number({{ $xmax }}); i += Number({{ $step }}) ) {
18+
x.push(i);
19+
try {
20+
y.push(eval("{{ $formula }}".replace(/x/g, "(" + i + ")")));
21+
} catch(e) {
22+
y.push(null);
23+
}
24+
}
25+
Plotly.newPlot("{{ $id }}", [{
26+
x: x,
27+
y: y,
28+
mode: 'lines',
29+
line: {color: '#0078d4'},
30+
name: "{{ $formula }}"
31+
}], {
32+
title: "{{ $title }}",
33+
xaxis: {title: "{{ $xlabel }}"},
34+
yaxis: {title: "{{ $ylabel }}"}
35+
}, {responsive: true});
36+
})();
37+
</script>
38+
39+
{{/* {{< plotly formula="Math.sin(x)" xmin="-6.28" xmax="6.28" step="0.05" title="y = sin(x)" xlabel="x" ylabel="y" >}} */}}

0 commit comments

Comments
 (0)