Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
getting remote changes
  • Loading branch information
carriewright11 committed Jul 12, 2023
2 parents 0d5869b + e429cf5 commit f98b180
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 14 deletions.
2 changes: 2 additions & 0 deletions docs/02-ethics.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Note that this is an incomplete list; additional ethical concerns will become ap

:::{.ethics}
Be transparent about what AI tools you use to write code. This help others to better understand how you created your code, as well as the possible sources that the AI tools might have used when helping you write code. It may also help with future unknown issues related to the use of these tools.

Some organizations and scientific societies have created guidelines or requirements for using AI in journal articles and conference submissions, like the [International Society for Computational Biology](https://www.iscb.org/iscb-policy-statements/iscb-policy-for-acceptable-use-of-large-language-models). Be aware of the requirements/guidelines for your field.
:::

**It is essential to address these ethical concerns and ensure that the use of AI in coding is done in a responsible and transparent manner.** This could be done through ensuring the quality of the data used to train AI systems, promoting transparency in AI-generated code, and implementing safeguards against the creation of harmful or biased code. By doing so, we can harness the potential of AI to improve and transform the way we write and optimize code while maintaining ethical standards.
Expand Down
6 changes: 3 additions & 3 deletions docs/04-refactoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ proc.time() - start_time

```
## user system elapsed
## 12.077 0.000 12.076
## 11.986 0.003 11.988
```

:::{.query}
Expand Down Expand Up @@ -575,7 +575,7 @@ proc.time() - start_time

```
## user system elapsed
## 0.665 0.363 0.697
## 0.745 0.504 0.832
```

The `outer()` function performs the same calculation as the nested loop in the original code, but more efficiently. It returns a matrix of all possible combinations of x and y values, with each element of the matrix being the product of the corresponding x and y values. The `rowSums()` function is then used to sum the elements of each row of the matrix, which is equivalent to summing the products of x and y for each index `i` in the original loop. This method avoids the need for the nested loop, resulting in a faster and more efficient computation.
Expand Down Expand Up @@ -603,7 +603,7 @@ proc.time() - start_time

```
## user system elapsed
## 0.334 0.296 0.402
## 0.394 0.452 0.536
```

One optimized way to perform the same calculation is by using the `%*%` operator to perform matrix multiplication. This can be done by converting x and y to matrices and transposing one of them so that their dimensions align for matrix multiplication. This code should be much faster than the original implementation because it takes advantage of highly optimized matrix multiplication algorithms in R.
Expand Down
1 change: 1 addition & 0 deletions docs/ethics-of-using-ai.html
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ <h2><span class="header-section-number">2.2</span> Major concerns</h2>
<p>Note that this is an incomplete list; additional ethical concerns will become apparent as we continue to use these new technologies. We highly suggest that users of these tools be <strong>transparent</strong> about the use of these tools, so that as new ethical issues emerge, we will be better prepared to understand the implications for specific coding projects.</p>
<div class="ethics">
<p>Be transparent about what AI tools you use to write code. This help others to better understand how you created your code, as well as the possible sources that the AI tools might have used when helping you write code. It may also help with future unknown issues related to the use of these tools.</p>
<p>Some organizations and scientific societies have created guidelines or requirements for using AI in journal articles and conference submissions, like the <a href="https://www.iscb.org/iscb-policy-statements/iscb-policy-for-acceptable-use-of-large-language-models">International Society for Computational Biology</a>. Be aware of the requirements/guidelines for your field.</p>
</div>
<p><strong>It is essential to address these ethical concerns and ensure that the use of AI in coding is done in a responsible and transparent manner.</strong> This could be done through ensuring the quality of the data used to train AI systems, promoting transparency in AI-generated code, and implementing safeguards against the creation of harmful or biased code. By doing so, we can harness the potential of AI to improve and transform the way we write and optimize code while maintaining ethical standards.</p>
</div>
Expand Down
2 changes: 2 additions & 0 deletions docs/no_toc/02-ethics.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Note that this is an incomplete list; additional ethical concerns will become ap

:::{.ethics}
Be transparent about what AI tools you use to write code. This help others to better understand how you created your code, as well as the possible sources that the AI tools might have used when helping you write code. It may also help with future unknown issues related to the use of these tools.

Some organizations and scientific societies have created guidelines or requirements for using AI in journal articles and conference submissions, like the [International Society for Computational Biology](https://www.iscb.org/iscb-policy-statements/iscb-policy-for-acceptable-use-of-large-language-models). Be aware of the requirements/guidelines for your field.
:::

**It is essential to address these ethical concerns and ensure that the use of AI in coding is done in a responsible and transparent manner.** This could be done through ensuring the quality of the data used to train AI systems, promoting transparency in AI-generated code, and implementing safeguards against the creation of harmful or biased code. By doing so, we can harness the potential of AI to improve and transform the way we write and optimize code while maintaining ethical standards.
Expand Down
6 changes: 3 additions & 3 deletions docs/no_toc/04-refactoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ proc.time() - start_time

```
## user system elapsed
## 207.366 0.057 207.422
## 231.734 0.076 231.807
```

:::{.query}
Expand Down Expand Up @@ -575,7 +575,7 @@ proc.time() - start_time

```
## user system elapsed
## 0.531 0.336 0.588
## 0.770 0.263 0.878
```

The `outer()` function performs the same calculation as the nested loop in the original code, but more efficiently. It returns a matrix of all possible combinations of x and y values, with each element of the matrix being the product of the corresponding x and y values. The `rowSums()` function is then used to sum the elements of each row of the matrix, which is equivalent to summing the products of x and y for each index `i` in the original loop. This method avoids the need for the nested loop, resulting in a faster and more efficient computation.
Expand Down Expand Up @@ -603,7 +603,7 @@ proc.time() - start_time

```
## user system elapsed
## 0.260 0.288 0.355
## 0.336 0.236 0.353
```

One optimized way to perform the same calculation is by using the `%*%` operator to perform matrix multiplication. This can be done by converting x and y to matrices and transposing one of them so that their dimensions align for matrix multiplication. This code should be much faster than the original implementation because it takes advantage of highly optimized matrix multiplication algorithms in R.
Expand Down
1 change: 1 addition & 0 deletions docs/no_toc/ethics-of-using-ai.html
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ <h2><span class="header-section-number">2.2</span> Major concerns</h2>
<p>Note that this is an incomplete list; additional ethical concerns will become apparent as we continue to use these new technologies. We highly suggest that users of these tools be <strong>transparent</strong> about the use of these tools, so that as new ethical issues emerge, we will be better prepared to understand the implications for specific coding projects.</p>
<div class="ethics">
<p>Be transparent about what AI tools you use to write code. This help others to better understand how you created your code, as well as the possible sources that the AI tools might have used when helping you write code. It may also help with future unknown issues related to the use of these tools.</p>
<p>Some organizations and scientific societies have created guidelines or requirements for using AI in journal articles and conference submissions, like the <a href="https://www.iscb.org/iscb-policy-statements/iscb-policy-for-acceptable-use-of-large-language-models">International Society for Computational Biology</a>. Be aware of the requirements/guidelines for your field.</p>
</div>
<p><strong>It is essential to address these ethical concerns and ensure that the use of AI in coding is done in a responsible and transparent manner.</strong> This could be done through ensuring the quality of the data used to train AI systems, promoting transparency in AI-generated code, and implementing safeguards against the creation of harmful or biased code. By doing so, we can harness the potential of AI to improve and transform the way we write and optimize code while maintaining ethical standards.</p>
</div>
Expand Down
6 changes: 3 additions & 3 deletions docs/no_toc/refactoring-code.html
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ <h2><span class="header-section-number">4.10</span> Code optimization</h2>
<span id="cb49-16"><a href="refactoring-code.html#cb49-16" aria-hidden="true" tabindex="-1"></a><span class="co"># End timer</span></span>
<span id="cb49-17"><a href="refactoring-code.html#cb49-17" aria-hidden="true" tabindex="-1"></a><span class="fu">proc.time</span>() <span class="sc">-</span> start_time</span></code></pre></div>
<pre><code>## user system elapsed
## 207.366 0.057 207.422</code></pre>
## 231.734 0.076 231.807</code></pre>
<div class="query">
<p>What is a faster, more optimized way of running the following R code?</p>
</div>
Expand All @@ -765,7 +765,7 @@ <h2><span class="header-section-number">4.10</span> Code optimization</h2>
<span id="cb51-12"><a href="refactoring-code.html#cb51-12" aria-hidden="true" tabindex="-1"></a><span class="co"># End timer</span></span>
<span id="cb51-13"><a href="refactoring-code.html#cb51-13" aria-hidden="true" tabindex="-1"></a><span class="fu">proc.time</span>() <span class="sc">-</span> start_time</span></code></pre></div>
<pre><code>## user system elapsed
## 0.531 0.336 0.588</code></pre>
## 0.770 0.263 0.878</code></pre>
<p>The <code>outer()</code> function performs the same calculation as the nested loop in the original code, but more efficiently. It returns a matrix of all possible combinations of x and y values, with each element of the matrix being the product of the corresponding x and y values. The <code>rowSums()</code> function is then used to sum the elements of each row of the matrix, which is equivalent to summing the products of x and y for each index <code>i</code> in the original loop. This method avoids the need for the nested loop, resulting in a faster and more efficient computation.</p>
</div>
<p>So much faster! We can look at another option by regenerating the response:</p>
Expand All @@ -784,7 +784,7 @@ <h2><span class="header-section-number">4.10</span> Code optimization</h2>
<span id="cb53-12"><a href="refactoring-code.html#cb53-12" aria-hidden="true" tabindex="-1"></a><span class="co"># End timer</span></span>
<span id="cb53-13"><a href="refactoring-code.html#cb53-13" aria-hidden="true" tabindex="-1"></a><span class="fu">proc.time</span>() <span class="sc">-</span> start_time</span></code></pre></div>
<pre><code>## user system elapsed
## 0.260 0.288 0.355</code></pre>
## 0.336 0.236 0.353</code></pre>
<p>One optimized way to perform the same calculation is by using the <code>%*%</code> operator to perform matrix multiplication. This can be done by converting x and y to matrices and transposing one of them so that their dimensions align for matrix multiplication. This code should be much faster than the original implementation because it takes advantage of highly optimized matrix multiplication algorithms in R.</p>
</div>
<p>While this second suggestion is faster, you will need to consider what aspects of the codebase are most important in each instance. For example, this code runs more quickly, but <a href="https://stat.ethz.ch/R-manual/R-patched/library/base/html/matmult.html">the <code>%*%</code> operator</a> might be unfamiliar to some R programmers. In cases where efficiency is less important, or the data are not large, you might consider maximizing readability.</p>
Expand Down
2 changes: 1 addition & 1 deletion docs/no_toc/search_index.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/refactoring-code.html
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ <h2><span class="header-section-number">4.10</span> Code optimization</h2>
<span id="cb49-16"><a href="refactoring-code.html#cb49-16" aria-hidden="true" tabindex="-1"></a><span class="co"># End timer</span></span>
<span id="cb49-17"><a href="refactoring-code.html#cb49-17" aria-hidden="true" tabindex="-1"></a><span class="fu">proc.time</span>() <span class="sc">-</span> start_time</span></code></pre></div>
<pre><code>## user system elapsed
## 12.077 0.000 12.076</code></pre>
## 11.986 0.003 11.988</code></pre>
<div class="query">
<p>What is a faster, more optimized way of running the following R code?</p>
</div>
Expand All @@ -765,7 +765,7 @@ <h2><span class="header-section-number">4.10</span> Code optimization</h2>
<span id="cb51-12"><a href="refactoring-code.html#cb51-12" aria-hidden="true" tabindex="-1"></a><span class="co"># End timer</span></span>
<span id="cb51-13"><a href="refactoring-code.html#cb51-13" aria-hidden="true" tabindex="-1"></a><span class="fu">proc.time</span>() <span class="sc">-</span> start_time</span></code></pre></div>
<pre><code>## user system elapsed
## 0.665 0.363 0.697</code></pre>
## 0.745 0.504 0.832</code></pre>
<p>The <code>outer()</code> function performs the same calculation as the nested loop in the original code, but more efficiently. It returns a matrix of all possible combinations of x and y values, with each element of the matrix being the product of the corresponding x and y values. The <code>rowSums()</code> function is then used to sum the elements of each row of the matrix, which is equivalent to summing the products of x and y for each index <code>i</code> in the original loop. This method avoids the need for the nested loop, resulting in a faster and more efficient computation.</p>
</div>
<p>So much faster! We can look at another option by regenerating the response:</p>
Expand All @@ -784,7 +784,7 @@ <h2><span class="header-section-number">4.10</span> Code optimization</h2>
<span id="cb53-12"><a href="refactoring-code.html#cb53-12" aria-hidden="true" tabindex="-1"></a><span class="co"># End timer</span></span>
<span id="cb53-13"><a href="refactoring-code.html#cb53-13" aria-hidden="true" tabindex="-1"></a><span class="fu">proc.time</span>() <span class="sc">-</span> start_time</span></code></pre></div>
<pre><code>## user system elapsed
## 0.334 0.296 0.402</code></pre>
## 0.394 0.452 0.536</code></pre>
<p>One optimized way to perform the same calculation is by using the <code>%*%</code> operator to perform matrix multiplication. This can be done by converting x and y to matrices and transposing one of them so that their dimensions align for matrix multiplication. This code should be much faster than the original implementation because it takes advantage of highly optimized matrix multiplication algorithms in R.</p>
</div>
<p>While this second suggestion is faster, you will need to consider what aspects of the codebase are most important in each instance. For example, this code runs more quickly, but <a href="https://stat.ethz.ch/R-manual/R-patched/library/base/html/matmult.html">the <code>%*%</code> operator</a> might be unfamiliar to some R programmers. In cases where efficiency is less important, or the data are not large, you might consider maximizing readability.</p>
Expand Down
2 changes: 1 addition & 1 deletion docs/search_index.json

Large diffs are not rendered by default.

Binary file modified manuscript/resources/chapt_screen_images/index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/chapt_screen_images/index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f98b180

Please sign in to comment.